本文整理汇总了PHP中common\models\LoginForm类的典型用法代码示例。如果您正苦于以下问题:PHP LoginForm类的具体用法?PHP LoginForm怎么用?PHP LoginForm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LoginForm类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testLoginCorrect
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();
}
示例2: actionLogin
/**
* 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]);
}
}
示例3: actionLogin
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]);
}
}
示例4: login
/**
* @param string $username
* @param string $password
*/
public function login($username, $password)
{
$loginForm = new LoginForm();
$this->actor->fillField('input[name="' . $loginForm->formName() . '[username]"]', $username);
$this->actor->fillField('input[name="' . $loginForm->formName() . '[password]"]', $password);
$this->actor->click('login-button');
}
示例5: actionLogin
/**
* 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]);
}
}
示例6: actionLogin
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]);
}
}
示例7: actionIndexadd
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]);
}
}
示例8: actionIndex
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 = '$_POST['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]);
}
}
示例9: actionLogin
/**
* 登录控制
* @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');
}
示例10: actionIndex
public function actionIndex()
{
$model = new LoginForm();
if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
Yii::$app->response->format = Response::FORMAT_JSON;
return ActiveForm::validate($model);
}
}
示例11: actionLogin
public function actionLogin()
{
$model = new LoginForm();
if ($model->load(\Yii::$app->request->post()) && $model->login()) {
$this->goBack();
}
return $this->render('login', ['model' => $model]);
}
示例12: run
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]);
}
示例13: testLoginCorrect
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();
});
}
示例14: actionLogin
/**
* 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();
}
}
示例15: actionLoginSubmit
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];
}