コード例 #1
0
 protected function performLocalLogin(LoginForm $localLogin, HybridauthForm $remoteLogin)
 {
     if (!isset($_POST['LoginForm'])) {
         return $localLogin;
     }
     $localLogin->setAttributes($_POST['LoginForm']);
     if ($localLogin->validate() && $localLogin->login()) {
         // don't forget to associate the new profile with remote provider
         if (!$remoteLogin->associate($localLogin->getIdentity()->getId())) {
             Yii::app()->user->setFlash('error', Yii::t('UsrModule.usr', 'Failed to associate current user with {provider}.', array('{provider}' => $remoteLogin->provider)));
             $this->redirect('login');
         }
         $this->afterLogin();
     }
     return $localLogin;
 }
コード例 #2
0
ファイル: AuthController.php プロジェクト: kolbensky/rybolove
 /**
  * Display admin login page.
  */
 public function actionIndex()
 {
     if (!Yii::app()->user->isGuest) {
         $this->redirect('/admin');
     }
     Yii::import('application.modules.admin.forms.LoginForm');
     $model = new LoginForm();
     $form = new CForm($model->config, $model);
     if (Yii::app()->request->getIsPostRequest()) {
         $model->attributes = $_POST['LoginForm'];
         if ($model->validate()) {
             // Authenticate user and redirect to the dashboard
             if ($model->rememberMe) {
                 $duration = 84600 * 7;
             } else {
                 $duration = 0;
             }
             Yii::app()->user->login($model->getIdentity(), $duration);
             Yii::app()->request->redirect($this->createUrl('/admin'));
         }
     }
     $this->render('auth', array('form' => $form));
 }
コード例 #3
0
 /**
  * @param  LoginForm             $localLogin
  * @param  HybridauthForm        $remoteLogin
  * @param  boolean|IUserIdentity $localIdentity if not false, try to authenticate this identity instead
  * @return LoginForm             validated $localLogin
  */
 protected function performLocalLogin(LoginForm $localLogin, HybridauthForm $remoteLogin, $localIdentity = false)
 {
     if (!isset($_POST['LoginForm'])) {
         return $localLogin;
     }
     if (is_object($localIdentity)) {
         // force to authorize against the $localIdentity
         $attributes = $localIdentity->getAttributes();
         if (isset($attributes['username'])) {
             $_POST['LoginForm']['username'] = $attributes['username'];
         }
     }
     $localLogin->setAttributes($_POST['LoginForm']);
     if ($localLogin->validate() && $localLogin->login()) {
         // don't forget to associate the new profile with remote provider
         if (!$remoteLogin->associate($localLogin->getIdentity()->getId())) {
             Yii::app()->user->setFlash('error', Yii::t('UsrModule.usr', 'Failed to associate current user with {provider}.', array('{provider}' => $remoteLogin->provider)));
             $this->redirect(array('login', 'provider' => $remoteLogin->provider));
         }
         $this->afterLogin();
     }
     return $localLogin;
 }