Add a configuration property for the forms to which the user restrictions are applied.

Original report

Problem/Motivation

Add options to check user restrictions only when registering, not when logging in.

This would be helpful for cases where you want an 'Official' account on the site but don't want users creating usernames with the word 'Official' in them.

Steps to reproduce

- Create 'sage_official' account
- Add 'official' as a blocked word on user accounts
- Logging in as sage_official is no longer allowed

Proposed resolution

- Create option to block on login and/or registration.
- Allow existing accounts to log in

Note: whitelisting is an option, but in my case there are over 100 accounts that need to be whitelisted. It would be easier if it only blocks users from creating new accounts with the blacklisted text.

Remaining tasks

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
#2 user_restriction_registrations.patch3.87 KBshank115
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

sagesolutions created an issue. See original summary.

shank115’s picture

StatusFileSize
new3.87 KB

Patch contains a "Block on registration only" checkbox to the User Restriction config form. When checked, the restriction will only apply during user registration, not during login.
This patch currently adds functionality only for username based restrictions.

version: 2.0.x

Drupal version: 10.5.2

sagesolutions’s picture

Hi @shank115, thanks for the patch. I reviewed it and I'm pretty sure you can remove the submit() function. The file extends EntityForm, which automatically sets fields into values.

Is it possible to create a Merge Request instead of a patch? It will be easier to update the code this way. Thanks!

avpaderno’s picture

Status: Active » Needs work
Issue tags: +Needs merge request
+  /**
+   * Whether to block this restriction only on registration.
+   *
+   * @var bool
+   */
+  protected $block_on_registration = FALSE;

User restrictions also allow a value to be used. Instead of $block_on_registration, the name should be more generic.

avpaderno’s picture

Assigned: Unassigned » avpaderno
avpaderno’s picture

Title: User restrictions only on registration » Add a property for the forms to which the restrictions are applied
Category: Feature request » Task
Issue summary: View changes

avpaderno’s picture

Issue tags: -Needs merge request

  • avpaderno committed 3b6d7719 on 2.0.x
    Issue #3511725: Add a property for the forms to which the restrictions...
avpaderno’s picture

Version: 2.0.x-dev » 3.0.x-dev

avpaderno’s picture

Issue summary: View changes

  • avpaderno committed c4a51615 on 3.0.x
    Issue #3511725: Add a property for the forms to which the restrictions...
avpaderno’s picture

Assigned: avpaderno » Unassigned
Status: Needs work » Fixed

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.