Ejemplo n.º 1
0
 /**
  * Authenticates the password.
  * This is the 'authenticate' validator as declared in rules().
  */
 public function authenticate($attribute, $params)
 {
     if (!$this->hasErrors()) {
         try {
             $_duration = $this->rememberMe ? 3600 * 24 * 30 : 0;
             /** @var PlatformUserIdentity $_identity */
             if (Session::userLogin($this->username, $this->password, $_duration, false)) {
                 return true;
             }
             $this->addError(static::ERROR_ATTRIBUTE, static::ERROR_MESSAGE);
         } catch (\Exception $_ex) {
             $this->addError(static::ERROR_ATTRIBUTE, $_ex->getMessage());
         }
     }
     return false;
 }