示例#1
0
 /**
  * Logs in a user using the provided username and password.
  * @return boolean whether the user is logged in successfully
  */
 public function login()
 {
     if ($this->validate()) {
         $loginResult = Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0);
         /*
          * Login history
          */
         if ($loginResult) {
             $newLoginEvent = new LoginHistory();
             $newLoginEvent->user_id = Yii::$app->user->id;
             $newLoginEvent->save();
         }
         return $loginResult;
     }
     return false;
 }
 public function actionClearlh()
 {
     $deleted = LoginHistory::deleteAll();
     if ($deleted) {
         echo "Deleted {$deleted} row \n";
         return true;
     } else {
         echo "Not exist new log\n";
     }
 }
示例#3
0
 public function actionClearlogins()
 {
     $deleted = LoginHistory::deleteAll();
     if ($deleted) {
         echo "Deleted {$deleted} row(s)\n";
         return true;
     } else {
         echo "nothing to delete\n";
     }
 }