-
-
Notifications
You must be signed in to change notification settings - Fork 825
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
Standaloneusers - split the public and private bits of User.SendPasswordReset into separate actions #31556
Conversation
🤖 Thank you for contributing to CiviCRM! ❤️ We will need to test and review this PR. 👷 Introduction for new contributors...
Quick links for reviewers...
|
d64ec96
to
664006b
Compare
retest this please |
Note: this would be a step on the way to this: ufundo#8 |
160c6b1
to
56e3578
Compare
ext/standaloneusers/Civi/Api4/Action/User/SendPasswordResetEmail.php
Outdated
Show resolved
Hide resolved
Looking at the sendPasswordReset action's authorization process, is this right:
Why not add "cms:administer users" to the User::permissions()? That would seem clearer and more assuring to me, given the default for that entity. Re admins triggering reset emails: I can see occasions when being able to en-masse send password resets (with a parameter for longer token life) could be useful. On the other hand, those are pretty darned rare, and this potentially increases an attack surface area. So I agree with you that on balance that it's better practice to ask users to do this and send them the link to the password reset request screen, in a normal email, if they want/need to (re)set.
DX/IDE autocomplete?
I don't have strong objections to it, so if you feel it's an improvement, fine. I guess it reduces the amount of code in each file, which is sometimes helpful to someone reasoning about the code, and sometimes it adds another level of abstraction that can be harder to follow. I can see, if you wanted the feature you now don't, that the case for the refactor was stronger. Edit: I've read through the code and it looks fine (see comments) and have r-run this and it works as designed. |
Thanks for reviewing @artfulrobot
I was working on the basis that it was defaulting to
Ah ok. Could a method hint comment achieve the same with less lines of code? Or I can just reinstate as was, IDM.
I haven't decided whether I want the feature or not. (I want it in the short term until we have the 2-step flow, but not in the long term). On balance I think I want the feature. |
@ufundo re permissions - yes see the note in the docblock for User::permissions.
I had the same thought! Probably. There's usually that weird repeated boilerplate that basically just passes on the $checkPermissions. IDM either, but I generally think it's good to stick with what everyone else has done unless there's a reason not to. Re admin feature to bulk send resets: not sure re the "2 step flow"? If you want it then we're going to need permission (for admins) to do it over ajax right? |
56e3578
to
dce0f6d
Compare
Ok, have reverted for now.
Sorry, by 2 step flow I meant a way to trigger an email to a user, that directs them to request a password reset. My main thought is on user creation - ideally you have a "welcome email" template and a "set your password screen / activate your account" screen. I've pulled through the ACL commit from the other branch which makes it possible to use |
Just to note in https://github.com/ufundo/civicrm-core/pull/8/files I only add the button to the UI on a per row basis, not in the select-multiple-rows action list. You could send in a big batch using Api4 explorer or API generally, but wasn't adding core UI for this. |
This looks good to me now 👍 @ufundo |
...on there's one weird ish thing, testing with api4 explorer, if I do it with an admin user, I get
|
Good catch, added a standard return array. Also noticed how it is updating the token even if the reset email workflow message is disabled. No worse than before, but if we do refactor the template prep, would be good to exit earlier if its not available. Added a TODO comment |
d04c6cc
to
b2ee81f
Compare
rebasing |
…ast to userId to int
…k for User.sendPasswordResetEmail
b2ee81f
to
6410d2b
Compare
Merge based on @artfulrobot's review. Seems better to get this in sooner than later so that it takes advantage of the RC period. |
Overview
Refactors User.SendPasswordReset into a public "RequestPasswordResetEmail" and private "SendPasswordResetEmail". Folds some of the helper functions from
Civi\Standalone\Security
into the classes that use them.Original motivation for this was step towards enabling an admin to send a password (re)set email for a newly created user. I have been having second thoughts about this*, but I think its a good cleanup refactor any way.
Before
After
SendPasswordResetEmail
orRequestPasswordResetEmail
orPasswordReset
classesTechnical Details
I would like to make some of the helpers that are used in one place protected / private, but they are currently used directly by SecurityTest, so have tagged them
@internal
I removed the explicit addition of extra Api actions in \Civi\Api4\User because they get picked up by the class-scanning, so it seems like unnecessary lines of code. Is there any reason to prefer explicit addition to the Api4 class?
Comments