Beispiel #1
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     /** @var Module $module */
     $module = Module::getInstance();
     /** @var Account $accountClass */
     $accountClass = $module->getClassName(Module::CLASS_ACCOUNT);
     return ArrayHelper::merge(parent::rules(), [[['email', 'username', 'phone', 'city_name'], 'required'], ['username', 'string', 'min' => Module::getParam(Module::PARAM_MIN_USERNAME_LENGTH)], ['email', 'email'], [['username', 'email'], 'unique', 'targetClass' => $accountClass], [['url'], 'url'], ['password', 'required'], ['password', 'string', 'min' => 6]]);
 }
Beispiel #2
0
 /**
  * Logs in a user using the provided email and password.
  *
  * @return boolean whether the user is logged in successfully
  */
 public function login()
 {
     if ($this->validate()) {
         $account = $this->getAccount();
         $duration = $this->rememberMe ? Module::getParam(Module::PARAM_LOGIN_EXPIRE_TIME) : 0;
         $success = Yii::$app->user->login($account, $duration);
         $account->updateAttributes(['lastLoginAt' => new Expression('NOW()')]);
         //$this->createHistoryEntry($account, $success);
         return $success;
     } else {
         return false;
     }
 }