Example #1
0
 public function actionLogin()
 {
     $this->layout = 'strepz_guest';
     if (!\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $this->_currentRegion = str_replace('Strepz ', '', Yii::$app->name);
     $model = new LoginForm();
     if ($model->load(Yii::$app->request->post())) {
         if ($user = $model->checkUsernameExists()) {
             $userRegion = strtoupper($user->region);
             if ($model->login()) {
                 if ($userRegion === $this->_currentRegion) {
                     return $this->goBack();
                 } elseif ($userRegion === 'US' && $this->_currentRegion === 'EU') {
                     if ($this->_auth_key = $model->getUser()->auth_key) {
                         $this->_username = $model->getUser()->username;
                         Yii::$app->user->logout();
                         return $this->redirect(Yii::$app->params['us_domain'] . 'index.php?r=site%2Flogin-auth&auth_key=' . $this->_auth_key . '&username='******'EU' && $this->_currentRegion === 'US') {
                     if ($this->_auth_key = $model->getUser()->auth_key) {
                         $this->_username = $model->getUser()->username;
                         Yii::$app->user->logout();
                         return $this->redirect(Yii::$app->params['eu_domain'] . 'index.php?r=site%2Flogin-auth&auth_key=' . $this->_auth_key . '&username='******'login', ['model' => $model]);
             }
         }
     } else {
         return $this->render('login', ['model' => $model]);
     }
 }