This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
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 is :
1) through the October reset password process (with an email key),
2) or through a profile vue in my app when the user is registered, invoking an October API through a plugin route.
In other words, can an authenticated user modify account information through an October route ? Thanks for your help.
Last updated
@Incremental you wouldn't be able to do it directly through the User plugin. You would need to instead expose an API through another plugin and manually update the user's password that way (as your second point suggests).
Thanks BennoThommo, can it be done with only : https://octobercms.com/docs/services/hashing-encryption#hashing
Hi, I finished my frontend code to send a new password and I receive from my route.php plugin the October error : "The email field is required." How could I assign the password to the right user ?
Route::post('Change-Pwd', function (Request $request) {
$user = new User;
// $user_id = $request->user_id;
$pwd = $request->password;
$user->password = Hash::make( $pwd );
$user->save();
PS : if I try to set $user->email I get an error saying the email is already registered... Thanks for your help
Last updated
Well, I changed my code to :
$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();
The password is successfully changed, but I can't login anymore ! Is there a trick with the hash ?
@Incremental I believe the hashing is done automatically here in the Hashable trait:
static::extend(function ($model) {
$model->bindEvent('model.beforeSetAttribute', function ($key, $value) use ($model) {
$hashable = $model->getHashableAttributes();
if (in_array($key, $hashable) && !empty($value)) {
return $model->makeHashValue($key, $value);
}
});
});
ref. https://github.com/octobercms/library/blob/develop/src/Database/Traits/Hashable.php#L34-L41
1-8 of 8