public function getToken()
 {
     $user = $this->user;
     $token = UserPasswordResetToken::findOne(['user_id' => $user->id]);
     if ($token == null) {
         $token = new UserPasswordResetToken();
         $token->user_id = $user->id;
         $token->token = $user->generatePasswordResetToken();
         $token->save();
     }
     return $token;
 }
 /**
  * Resets password.
  *
  * @return boolean if password was reset.
  */
 public function resetPassword()
 {
     $this->_token->user->setPassword($this->password);
     return $this->_token->user->save() && $this->_token->delete();
 }
Exemple #3
0
 public function getPasswordResetToken()
 {
     return $this->hasOne(UserPasswordResetToken::className(), ['user_id' => 'id']);
 }