-
Notifications
You must be signed in to change notification settings - Fork 295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UsersTable doesn't have any email validation rules #1106
Comments
At the same time, users/src/Model/Table/UsersTable.php Line 145 in 9f9f49b
… which clearly some people don't want and this plugin actually allows using email instead. I have all of that configured and the users controller, processing the login request, does recognise that. So the UsersTable validation rules should recognise that too? My current workaround when saving a user that shouldn't have a
|
The plugins provides "one way" of doing things, but all projects are different, for example your case where you don't need the username but only the email. That's the reason we've tried to make it extendable https://github.com/CakeDC/users/blob/14.next-cake5/Docs/Documentation/Extending-the-Plugin.md in an easy way, so you can use what you like and replace what you don't need. I think you are looking for a custom UsersTable, implementing your own validation rules and columns. |
Right, I just believed I am not asking for anything niche enough to warrant a custom table. After all, I am wanting to use email instead of username, which is a concept already known, common enough, and covered in the plugin documentation. You even already have a flag like this implemented: users/src/Model/Table/UsersTable.php Line 53 in 9f9f49b
users/src/Model/Table/UsersTable.php Lines 205 to 210 in 9f9f49b
Shouldn't You also have these flags: users/Docs/Documentation/Configuration.md Lines 191 to 202 in 9f9f49b
If (either of?) these are present, can't we tell confidently enough that email needs to be validated? I understand though that deciding at this point that username is not wanted maybe is a stretch. Either way, in my case I am happy with the workaround of UPD simply removing the
Finally, if we can eventually set the email to be preferred, it would be only fair to apply the same rigorous checks to it being unique etc., as there are for the username. |
I see your point, and I agree we add validation for the email field by default. Thank you. |
Thank you! |
@steinkel okay, after sleeping on it, I have to agree extending If someone else finds this, here's my users table that prioritises
Note: Because there's no way to tell the parent |
Shouldn't
\CakeDC\Users\Model\Table\UsersTable
offer validation rules foremail
?\Cake\Validation\Validator::email()
can be used. (CakePHP Book → Modelless Forms → Creating a Form is an example.)For an experiment, I added:
... right here:
users/src/Model/Table/UsersTable.php
Line 138 in 9f9f49b
Worked perfectly for me, but I understand I'm probably missing a bigger picture as this could be not for every use case.
And yet, for a rather common use case where email is needed, I would argue the plugin should somehow recognise it and enable the email validation out of the box.
The text was updated successfully, but these errors were encountered: