User password change from a route API ?
Closed this issue · 11 comments
Hi, I'm using October and developping a frontend app in Vue.js (Quasar framework) and JWT Auth. I'm wondering if the way to modify a password for an existing user from my app.
I made an axios request to a plugin API and tried the following code in my route.php
$user = User::findByEmail( $user_email );
$pwd = $request->password; // Retreive password in the request
$new_pwd = Hash::make( $pwd );
$user->password = $new_pwd;
$user->password_confirmation = $new_pwd;
$user->save();
but after the change, I'm not able to log anymore, I need to reset the password from the backend...
Do I really need to hash the password ? Thanks
No, you do not hash the password, the user model does that for you. $user->password = post('password');
should be enough, and then the password will be hashed when the model is saved.
Ok thanks a lot Luke, I was confused by October doc.
And to change avatar, do you have some recommendations ?
@Incremental92 please use github discussions in the main repo for questions.
@mjauvin I would like to avoid encouraging the discussions tab in the main repo for plugin questions right now
Then maybe we should enable discussions in the plugins repo? @LukeTowers
Possibly, although I'd have to do that manually for every single repo. @bennothommo do you think adding discussions tabs to all the rainlab repos is worth the effort? Or perhaps just for a select few?
@LukeTowers @mjauvin I haven't really found a net benefit for the discussions yet. The "answered" feature is probably the only useful thing. All it adds is just one more place we have to keep an eye on.
@bennothommo I don't really mind it all that much personally, I only ever work from my notifications anyways so there's no difference to me as to how I keep track of issues vs discussions. It is somewhat nice to have a place for questions to be directed to instead of pretending to be issues, and the answered feature is nice too. I feel like in order to get the most benefit out of them however I'd have to go through and actually setup proper repo managing tools for all the rainlab repos at once to bring them more in line with the core october repos (i.e. issue templates, github policies, tag syncing, github actions, etc) which is valuable work but not very high priority for me right now.
Sorry to create this discussion, I'm still a beginner on October ;-)
It seems that all knowing is here. I posted in October forum, but had no response :
https://octobercms.com/forum/post/how-to-upload-an-avatar-image-from-frontend-to-user-plugin
For the community, maybe the answers to these trivial questions could be more developed in October documentation : modify user profile, password and avatar and route API for client applications ?
Thanks
@Incremental92 feel free to provide a PR to wherever you think it would be most likely to be found by someone looking to do what you're doing.
OK I'll do a compilation of all my User management !