Hi All
What is the best way to log in an user without login form ?
I want to login the user after of reseting of his account.
Note I get his username by request and I want auhenticate him without prompt to login
Thanks
Hi All
What is the best way to log in an user without login form ?
I want to login the user after of reseting of his account.
Note I get his username by request and I want auhenticate him without prompt to login
Thanks
Hello there,
http://www.yiiframework.com/doc/api/1.1/CWebUser
So you have the user new password or no?
$identity = new UserIdentity($this->username, $this->newPassword);
$identity->authenticate();
Yii::app()->user->login($identity);
or if you don’t have the password, I guess you could pass false to your UserIdentity and check if it’s false there, you don’t verify it…
Hi @Bennouna, thanks for your response!
because the password is already hashed I don’t want to do that by hacking way
A solution I found is to make another method in UserIdentity class
$identity = new UserIdentity($this->username, '');
$identity->ResetAuthenticate($idUserToReset);
Yii::app()->user->login($identity);
//where ResetAuthenticate reside in UserIdentity class
public function ResetAuthenticate($id=null) {
$user = User::model()->findByPk($id);
...if the account have to reset then...
$this->id = $user->id;
}
It works! but is the best way to do that?
Thanks
I don’t personally know if it’s the best, it does the job
You have to log the user in programmatically anyway, no?
I think that is reasonable way, it works but I don’t know if I missed something
Yes I don’t want send to the user a new pass by email instead of that I prefer a confirmation link to change his password directly
If someone has experience with this issue please share that