Support the ongoing development of Laravel.io →
posted 10 years ago
Authentication
Last updated 2 years ago.
0

Okay, I just needed to get this thing out the door. I've bypassed the standard Laravel stuff and just go direct to the remote system to change the password. Would be interested to know how others do it, but I have something that works for me now.

Last updated 2 years ago.
0

I'm not sure if I understand your problem, but isn't setting the user's password enough? I use the following method in my User model,

/**
 * Set the password to be hashed when saved
 */
public function setPasswordAttribute($password)
{
    $this->attributes['password'] = \Hash::make($password);
}

And then I can simply do the following:

$user = Auth::user();
$user->password = 'MyAwesomePassword';
$user->save();

Then logging in using Auth::check($user->email, 'MyAwesomePassword') should still work.

Last updated 2 years ago.
0

I have created a new setPassword() method on the user to hash the password and set a flag to show that it is dirty. The save() method recognises the flag and calls up the appropriate remote APIs to set the password. The users are not a simple flat eloquent table - they are at the end of some RPC APIs.

What I wanted to do, is make sure that I am following the "Laravel way" as much as possible, so if the users ever change to a new system or a new API, the main application would not need to know about it and all I would need to change are the Auth drivers.

Thanks :-)

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

judgej judgej Joined 4 Mar 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.