示例#1
0
 /**
  * Creates a form model given a token.
  *
  * @param  string                          $token
  * @param  array                           $config name-value pairs that will be used to initialize the object properties
  * @throws \yii\base\InvalidParamException if token is empty or not valid
  */
 public function __construct($token, $config = [])
 {
     if (empty($token) || !is_string($token)) {
         throw new InvalidParamException('Password reset token cannot be blank.');
     }
     $this->_user = UserRecord::findByPasswordResetToken($token);
     if (!$this->_user) {
         throw new InvalidParamException('Wrong password reset token.');
     }
     parent::__construct($config);
 }
示例#2
0
 /**
  * @param array $token
  * @param array $config
  */
 public function __construct($token, $config = [])
 {
     if (empty($config['scenario'])) {
         $config['scenario'] = self::SCENARIO_DEFAULT;
     }
     if (empty($token) || !is_string($token)) {
         throw new InvalidParamException('Password reset token cannot be blank.');
     }
     parent::__construct($config);
     $this->user = User::findByPasswordResetToken($token, $this->isNewUserScenario() ? User::STATUS_NEW : User::STATUS_ACTIVE);
     if (!$this->user) {
         throw new InvalidParamException('Wrong password reset token.');
     }
     $this->token = $token;
 }