public function testCantLoginWithoutPassword() { test::double('common\\models\\User', ['validatePassword' => true]); $model = new LoginForm(); $model->username = '******'; $this->assertFalse($model->login()); $model->password = '******'; $this->assertTrue($model->login()); }
public function actionLogin() { if (!\Yii::$app->user->isGuest) { return $this->goHome(); } $model = new LoginForm(); $serviceName = Yii::$app->getRequest()->getQueryParam('service'); if (isset($serviceName)) { /** @var $eauth \nodge\eauth\ServiceBase */ $eauth = Yii::$app->get('eauth')->getIdentity($serviceName); $eauth->setRedirectUrl(Yii::$app->getUser()->getReturnUrl()); $eauth->setCancelUrl(Yii::$app->getUrlManager()->createAbsoluteUrl('site/login')); try { if ($eauth->authenticate()) { $identity = User::findByEAuth($eauth); Yii::$app->getUser()->login($identity); // special redirect with closing popup window $eauth->redirect(); } else { // close popup window and redirect to cancelUrl $eauth->cancel(); } } catch (\nodge\eauth\ErrorException $e) { // save error to show it later Yii::$app->getSession()->setFlash('error', 'EAuthException: ' . $e->getMessage()); // close popup window and redirect to cancelUrl // $eauth->cancel(); $eauth->redirect($eauth->getCancelUrl()); } } elseif ($model->load(Yii::$app->request->post()) && $model->login()) { return $this->goBack(Yii::$app->homeUrl); } else { return $this->render('login', ['model' => $model]); } }
public function actionLogin() { if (!\Yii::$app->user->isGuest) { return $this->goHome(); } $model = new LoginForm(); if ($model->load(Yii::$app->request->post()) && $model->login()) { $request = ""; $dosen = \backend\modules\aitk\models\AitkRDosen::findOne(['account_id' => Yii::$app->user->id]); $asrama = \backend\modules\aitk\models\AitkRAsrama::findOne(['account_id' => Yii::$app->user->id]); if (isset($dosen) || isset($asrama)) { if (isset($dosen)) { $jumlah_request_dosen = \backend\modules\aitk\models\AitkRequest::find()->where(['status_dosen' => NULL, 'dosen_wali' => $dosen->dosen_id])->count(); } $jumlah_request_asrama = \backend\modules\aitk\models\AitkRequest::find()->where(['status_dosen' => 1, 'status_asrama' => NULL])->count(); $total_request = isset($dosen) ? $jumlah_request_dosen : (isset($asrama) ? $jumlah_request_asrama : 0); $url = isset($dosen) ? 'dosenwali' : 'asrama'; if ($total_request > 0) { Yii::$app->getSession()->setFlash('info', ['type' => 'info', 'delay' => 100000, 'icon' => 'glyphicon glyphicon-warning-sign', 'message' => 'Anda Memiliki <a href=' . \yii\helpers\Url::to('index.php?r=aitk/request/' . $url) . '><b>' . $total_request . ' Pending Request</b></a> ', 'title' => 'Pending Request']); } } return $this->redirect(['index']); } else { return $this->render('login', ['model' => $model]); } }
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]); } }
/** * Logs in a user. * * @return mixed */ public function actionLogin() { $this->layout = 'main_login'; if (!\Yii::$app->user->isGuest) { return $this->goHome(); } $model = new LoginForm(); $signupModel = new SignupForm(); if ($model->load(Yii::$app->request->post()) && $model->login()) { return $this->goBack(); } elseif ($signupModel->load(Yii::$app->request->post())) { if ($user = $signupModel->signup()) { if (Yii::$app->getUser()->login($user)) { $profile = new ProfileCrud(); $profile->user_id = $user->id; $profile->fullname = $user->username; $profile->email = $user->email; $profile->save(); return $this->goHome(); } } } else { return $this->render('login', ['model' => $model, 'signupModel' => $signupModel]); } }
public function actionIndexadd() { if (Yii::$app->user->isGuest) { $model = new LoginForm(); if ($model->load(Yii::$app->request->post()) && $model->login()) { return $this->goBack(); } else { return $this->render('/site/login', ['model' => $model]); } } else { $Order = new Order(); $Order->user_id = Yii::$app->user->identity->id; $Order->date_time = date('Y-m-d H:i:s'); $Order->status_id = '1'; $Order->save(); $Card = new CardList(); $Products = $Card->getCardAndCardList(Yii::$app->user->identity->id); $Ord = new Order(); $order_id = $Ord->GetOrderId(Yii::$app->user->identity->id); for ($i = 0; $i < sizeof($Products); $i++) { $Orderlist = new Orderlist(); $Orderlist->order_id = $order_id[0]['MAX(`order_id`)']; $Orderlist->product_id = $Products[$i]['product_id']; $Orderlist->quantity = $Products[$i]['quantity']; $Orderlist->save(); } $card = new Card(); $card->DeleteCardId(Yii::$app->user->identity->id); $order = $Ord->GetOrdersFromID(Yii::$app->user->identity->id); $user = User::find()->where(['id' => Yii::$app->user->identity->id])->one(); return $this->render('index', ['user' => $user, 'order' => $order]); } }
public function testLoginCorrect() { $model = new LoginForm(['username' => 'bayer.hudson', 'password' => 'password_0']); expect('model should login user', $model->login())->true(); expect('error message should not be set', $model->errors)->hasntKey('password'); expect('user should be logged in', Yii::$app->user->isGuest)->false(); }
public function actionIndex() { if (Yii::$app->user->isGuest) { $model = new LoginForm(); if ($model->load(Yii::$app->request->post()) && $model->login()) { return $this->goBack(); } else { return $this->render('/site/login', ['model' => $model]); } } else { if (!empty($_POST)) { $model = new User(); $model = User::find()->where(['id' => Yii::$app->user->identity->id])->one(); //$model->username = '******'username']'; //$model->email = '$_POST['email']'; $model->country = $_POST['country']; $model->city = $_POST['city']; $model->street = $_POST['street']; $model->zip_code = $_POST['zip_code']; $model->save(); } $user = User::find()->where(['id' => Yii::$app->user->identity->id])->one(); return $this->render('index', ['user' => $user]); } }
/** * 登录控制 * @return type */ public function actionLogin() { if (!\Yii::$app->user->isGuest) { $this->redirect('/member/index.html'); } $time = time(); $time = $time - 10; if (!empty(\Yii::$app->request->get('id')) && !empty(\Yii::$app->request->get('stoken'))) { $user_id = \Yii::$app->request->get('id'); $stoken = \Yii::$app->request->get('stoken'); //$user = Users::model()->find(" user_id=:id AND repstaken=:repstaken AND repsativetime>=:time", array(":id"=>$user_id,":repstaken" => $stoken, ":time" => $time)); //echo $user_id;exit; $user = User::find()->where(" user_id=:id", [":id" => $user_id])->one(); //$user = User::model()->find(" user_id=:id", array(":id" => $user_id)); if ($user) { $loginform = new LoginForm(); $loginform->setAttributes(['username' => $user->username, 'password' => $user->password, 'rememberMe' => true]); if ($loginform->login(2)) { $this->redirect('/member/index.html'); \Yii::$app->end(); } } } $this->redirect('/public/nologin.html'); }
/** * Logs in a user. * * @return mixed */ public function actionLogin() { $this->layout = 'main_login'; if (!\Yii::$app->user->isGuest) { return $this->goHome(); } $model = new LoginForm(); $signupModel = new SignupForm(); if ($model->load(Yii::$app->request->post()) && $model->login()) { return $this->goBack(); } elseif ($signupModel->load(Yii::$app->request->post())) { if ($user = $signupModel->signup()) { if (Yii::$app->getUser()->login($user)) { $profile = new ProfileCrud(); $profile->scenario = 'signup'; $profile->user_id = $user->id; $profile->fullname = $user->username; $profile->email = ' '; $profile->save(); if ($profile->sendEmail($user->email, 1)) { Yii::$app->session->setFlash('success', 'Hi ' . $user->username . ', selamat bergabung. Mohon lakukan verifikasi email dan lengkapi profile anda. '); } else { Yii::$app->session->setFlash('error', 'Maaf, kami tidak dapat mengirimkan email verifikasi untuk anda.'); } return $this->goHome(); } } } else { return $this->render('login', ['model' => $model, 'signupModel' => $signupModel]); } }
public function actionLogin() { $model = new LoginForm(); if ($model->load(\Yii::$app->request->post()) && $model->login()) { $this->goBack(); } return $this->render('login', ['model' => $model]); }
public function run() { $model = new LoginForm(); if ($model->load(\Yii::$app->request->post()) && $model->login()) { \Yii::$app->controller->redirect(\Yii::$app->controller->goBack()); } return $this->render('login', ['model' => $model]); }
public function testLoginCorrect() { $model = new LoginForm(['username' => 'admin', 'password' => 'admin']); $this->specify('用户应该正常登录', function () use($model) { expect('login方法应该返回true', $model->login())->true(); expect('密码错误信息应该不被设置', $model->errors)->hasntKey('password'); expect('用户应该登录成功', Yii::$app->user->isGuest)->false(); }); }
/** * Logs in a user. * * @return mixed */ public function actionLogin() { $model = new LoginForm(); if ($model->load(Yii::$app->request->post()) && $model->login()) { return $this->goBack(); } else { return $this->goHome(); } }
public function testLoginCorrect() { $model = new LoginForm(['username' => '*****@*****.**', 'password' => '$2y$13$Jpkp5Aibej7Luvys6im9CO3WpYeWRkBpJ4VW5xlFUu3.FiF6K/Skm']); $this->specify('user should be able to login with correct credentials', function () use($model) { expect('model should login user', $model->login())->true(); expect('error message should not be set', $model->errors)->hasntKey('password'); expect('user should be logged in', Yii::$app->user->isGuest)->false(); }); }
public function actionLoginSubmit() { Yii::$app->response->format = Response::FORMAT_JSON; $model = new LoginForm(); if ($model->load(["LoginForm" => Yii::$app->request->post()]) && $model->login()) { return ["code" => 200, "msg" => "登录成功!"]; } return ["code" => 300, "msg" => "登录失败", "errors" => $model->errors]; }
public function actionLogin() { $model = new LoginForm(); if ($model->load(Yii::$app->request->post()) && $model->login()) { return $this->redirect('/board/select'); } else { return $this->render('login', ['model' => $model]); } }
public function actionLogin() { $model = new LoginForm(); if ($model->load($_POST) && $model->login()) { return $this->redirect(array('site/index')); } else { return $this->render('login', array('model' => $model)); } }
/** * This method implemented to demonstrate the receipt of the token. * Do not use it on production systems. * @return string AuthKey or model with errors */ public function actionLogin() { $model = new LoginForm(); if ($model->load(\Yii::$app->getRequest()->getBodyParams(), '') && $model->login()) { return \Yii::$app->user->identity->getAuthKey(); } else { return $model; } }
public function testLoginCorrect() { $model = new LoginForm(['login' => 'bayer.hudson', 'password' => 'password_0']); $this->specify('user should be able to login with correct credentials', function () use($model) { expect('model should login user', $model->login())->true(); expect('error message should not be set', $model->errors)->hasntKey('password'); expect('user should be logged in', Yii::$app->user->isGuest)->false(); }); }
protected function doLogin($view, $username = null) { $model = new LoginForm(); if ($model->load(Yii::$app->request->post()) && $model->login()) { return $this->goBack(); } else { $model->username = $username; return $this->render($view, compact('model')); } }
public function actionLogin() { $model = new LoginForm(); if ($model->load(Yii::$app->getRequest()->getBodyParams(), '') && $model->login()) { return ['access_token' => Yii::$app->user->identity->getAuthKey()]; } else { $model->validate(); return $model; } }
public function actionLogin() { $model = new LoginForm(); $requestedData = \Yii::$app->getRequest()->post('fb_token') ? \Yii::$app->getRequest()->post() : \Yii::$app->getRequest()->get(); if ($model->load($requestedData, '') && $model->login()) { return \Yii::$app->user->identity->getAuthKey(); } else { return $model; } }
public function actionLogin() { $model = new LoginForm(); if ($model->load(Yii::$app->getRequest()->getBodyParams(), '') && $model->login()) { // return Yii::$app->user->identity->getAuthKey(); // return ApiResponse::reponseWithStatus(['accessToken' => Yii::$app->user->identity->getAuthKey(), 'NameUser' => Yii::$app->user->identity->username, 'NameUser' => Yii::$app->user->identity->id]); return ApiResponse::reponseWithStatus(['accessToken' => Yii::$app->user->identity->getAuthKey(), 'NameUser' => Yii::$app->user->identity->username, 'idUser' => Yii::$app->user->identity->id]); } else { return ApiResponse::reponseWithStatus(Yii::$app->getRequest()->getBodyParams(), 403); } }
/** * login api * @return type */ public function actionLogin() { $request = \Yii::$app->request; $data = $request->_get(); $model = new LoginForm(); if ($model->load($data, '') && $model->login()) { return ['code' => 0, 'msg' => '登录成功']; } else { return ['code' => 1, 'msg' => '用户名或密码错误']; } }
public function actionLogin() { if (!Yii::$app->user->isGuest) { return $this->goHome(); } $loginModel = new LoginForm(); if ($loginModel->load(Yii::$app->request->post()) && $loginModel->login()) { return $this->goBack(); } return $this->render('login', ['loginModel' => $loginModel]); }
public function run() { if ($this->visible) { $user = new LoginForm(); if ($user->load(\Yii::$app->request->post()) && $user->login()) { return \Yii::$app->getResponse()->refresh(); } else { return $this->render('loginWidget', ['user' => $user, 'title' => $this->title]); } } }
public function actionSubmitLogin() { $model = new LoginForm(); if ($model->load(Yii::$app->request->post())) { if ($model->login()) { echo "success"; } else { echo "Incorrect email or password."; } } }
public function actionLoginuser() { if (!\Yii::$app->user->isGuest) { return $this->goHome(); } $model = new LoginForm(); if ($model->load(Yii::$app->request->post()) && $model->login()) { return $this->goBack(); } else { return $this->render('loginuser', ['model' => $model]); } }
/** * 用户登陆控制器 * @return string|\yii\web\Response */ public function actionLogin() { if (!wanhunet::$app->user->isGuest) { return !wanhunet::$app->user->isGuest; } $model = new LoginForm(wanhunet::$app->request->post()); if ($model->login()) { return true; } else { return current($model->getFirstErrors()); } }