• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP UserIdentity类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中UserIdentity的典型用法代码示例。如果您正苦于以下问题:PHP UserIdentity类的具体用法?PHP UserIdentity怎么用?PHP UserIdentity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了UserIdentity类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: actionLogin

 /**
  * Displays the login page
  */
 public function actionLogin()
 {
     if (!Yii::app()->request->getIsAjaxRequest()) {
         $this->render('//mlogin');
     } else {
         $username = Yii::app()->request->getParam('username');
         $passwd = Yii::app()->request->getParam('passwd');
         $captcha = Yii::app()->request->getParam('captcha');
         $autologin = Yii::app()->request->getParam('autologin');
         $oValidate = new CaptchaExtendedAction($this, 'captcha');
         $bValidate = $oValidate->validate($captcha, false);
         if (ENV != 'dev' && !$bValidate) {
             $re = new ReturnInfo(FAIL_RET, '验证码错误');
             echo CJSON::encode($re);
             Yii::app()->end();
         }
         $identity = new UserIdentity($username, $passwd);
         $identity->authenticate();
         $user = Yii::app()->user;
         if (!$autologin) {
             $user->login($identity, 0);
         } else {
             $user->login($identity, 3600 * 24 * 30);
         }
         $rt = new ReturnInfo(SUCCESS_RET, 'login_success');
         echo CJSON::encode($rt);
     }
 }
开发者ID:wheatma,项目名称:react_study,代码行数:31,代码来源:LoginController.php


示例2: testUserIdentity

 public function testUserIdentity()
 {
     $oIden = new UserIdentity('', '');
     $this->assertFalse($oIden->authenticate());
     $oIden = new UserIdentity('admin', 'admin');
     $this->assertTrue($oIden->authenticate());
 }
开发者ID:rawaludin,项目名称:jenkins-yii,代码行数:7,代码来源:ExampleText.php


示例3: authenticate

 /**
  * Authenticates the password.
  * This is the 'authenticate' validator as declared in rules().
  */
 public function authenticate($attribute, $params)
 {
     if (!$this->hasErrors()) {
         $identity = new UserIdentity($this->username, $this->password);
         $identity->authenticate();
         switch ($identity->errorCode) {
             case UserIdentity::ERROR_NONE:
                 $duration = $this->rememberMe ? 3600 * 24 * 30 : 0;
                 // 30 days
                 Yii::app()->user->login($identity, $duration);
                 break;
             case UserIdentity::ERROR_USERNAME_INVALID:
                 $this->addError('username', Yii::t('lan', 'Username is incorrect.'));
                 break;
             case UserIdentity::ERROR_BANNED:
                 $this->addError('username', Yii::t('lan', 'User is banned.'));
                 break;
             case UserIdentity::ERROR_CONFIRMREGISTRATION:
                 $this->addError('username', Yii::t('lan', 'Confirm user email.'));
                 break;
             default:
                 $this->addError('password', Yii::t('lan', 'Password is incorrect.'));
                 break;
         }
     }
 }
开发者ID:Greka163,项目名称:Yii-blog-new,代码行数:30,代码来源:LoginForm.php


示例4: init

 public function init()
 {
     parent::init();
     if (isset($_GET["src"]) && $_GET["src"] == "ads") {
         Yii::app()->session['src'] = 'ads';
     }
     //get userPhone
     if (Yii::app()->user->isGuest) {
         $identity = new UserIdentity(null, null);
         $type = 'autoLogin';
         if ($identity->userAuthenticate($type, $this->deviceOs)) {
             Yii::app()->user->login($identity);
         }
     }
     $this->userPhone = Yii::app()->user->getState('msisdn');
     $this->banners = WapBannerModel::getBanner('wap');
     //chk is subscribe
     if (!empty($this->userPhone)) {
         $this->isSub = WapUserSubscribeModel::model()->chkIsSubscribe($this->userPhone);
     }
     if (Yii::app()->user->getState('is3g') == 1) {
         $this->is3g = true;
     }
     $isTouch = $this->_isTouchLayout();
     if (!$isTouch) {
         $this->layout = 'application.views.wap.layouts.main';
     }
 }
开发者ID:giangnh264,项目名称:mobileplus,代码行数:28,代码来源:TController.php


示例5: actionActivation

	/**
	 * Activation user account
	 */
	public function actionActivation () {
		$email = $_GET['email'];
		$activkey = $_GET['activkey'];
		if ($email&&$activkey) {
			$find = User::model()->notsafe()->findByAttributes(array('email'=>$email));
			if (isset($find)&&$find->status) {
			    $this->render('/user/message',array('title'=>UserModule::t("User activation"),'content'=>UserModule::t("You account is active.")));
			} elseif(isset($find->activkey) && ($find->activkey==$activkey)) {
				$find->activkey = UserModule::encrypting(microtime());
				$find->status = 1;
				$find->save();
                if (!Yii::app()->controller->module->autoLogin) {
                    $this->render('/user/message',array('title'=>UserModule::t("User activation"),'content'=>UserModule::t("You account is activated.")));
                } else {
                    $identity=new UserIdentity($find->username, '');
                    $identity->authenticate(true);
                    Yii::app()->user->login($identity,0);
                    Yii::app()->user->setFlash('userActivationSuccess', UserModule::t("You account is activated."));
                    $this->redirect(Yii::app()->controller->module->returnUrl);
                }
			} else {
			    $this->render('/user/message',array('title'=>UserModule::t("User activation"),'content'=>UserModule::t("Incorrect activation URL.")));
			}
		} else {
			$this->render('/user/message',array('title'=>UserModule::t("User activation"),'content'=>UserModule::t("Incorrect activation URL.")));
		}
	}
开发者ID:rallin,项目名称:yii-user,代码行数:30,代码来源:ActivationController.php


示例6: handleBeginRequest

 public function handleBeginRequest($event)
 {
     if (Yii::app()->user->id == null) {
         $identity = new UserIdentity();
         if ($identity->authenticate()) {
             Yii::app()->user->login($identity);
         }
     }
     $app = Yii::app();
     if (isset($_POST['lang'])) {
         $app->language = $_POST['lang'];
         $app->user->setState('lang', $_POST['lang']);
         $cookie = new CHttpCookie('lang', $_POST['lang']);
         $cookie->expire = time() + 60 * 60 * 24 * 365;
         // (1 year)
         Yii::app()->request->cookies['lang'] = $cookie;
     } else {
         if ($app->user->hasState('lang')) {
             $app->language = $app->user->getState('lang');
         } else {
             if (isset(Yii::app()->request->cookies['lang'])) {
                 $app->language = Yii::app()->request->cookies['lang']->value;
             }
         }
     }
 }
开发者ID:Romandre90,项目名称:vectortraveler,代码行数:26,代码来源:BeginRequest.php


示例7: actionRegister

 public function actionRegister()
 {
     $model = BaseActiveRecord::newModel('User', 'register');
     $modelClass = get_class($model);
     $this->performAjaxValidation($model, 'register-form');
     if (isset($_POST[$modelClass])) {
         $model->attributes = $_POST[$modelClass];
         //Создаем indentity раньше сохранения модели
         //т.к. после сохранения поле user_password измениться на хеш
         $identity = new UserIdentity($model->name, $model->user_password);
         $model->onAfterSave = array($this, 'sendRegisterMessage');
         if ($model->save()) {
             //если разрешено сразу авторизовать пользователя
             if (Yii::app()->getModule('user')->immediatelyAuthorization) {
                 //загружаем модель пользователя
                 $identity->authenticate();
                 //Сразу авторизуем пользователя
                 Yii::app()->user->login($identity);
                 Yii::app()->user->setFlash('registerSuccess', 'Регистрация успешно завершена.');
             } else {
                 Yii::app()->user->setFlash('registerSuccess', 'Регистрация успешно завершена. Теперь вы можете войти на сайт через форму авторизации.');
             }
             $this->redirect(Yii::app()->createUrl($this->getRedirectRouteAfterRegister()));
         }
     }
     $this->render('/register', array('model' => $model));
 }
开发者ID:Cranky4,项目名称:npfs,代码行数:27,代码来源:CabinetController.php


示例8: login

 protected function login()
 {
     $identity = new UserIdentity();
     $identity->applyUserModel($this->_userModel);
     Yii::app()->user->login($identity);
     Yii::app()->user->setModel($this->_userModel);
 }
开发者ID:andrelinoge,项目名称:rezydent,代码行数:7,代码来源:RegistrationForm.php


示例9: actionLogin

 public function actionLogin()
 {
     if (!empty($_POST) && $_POST['run'] === "login") {
         if ($identity === null) {
             $identity = new UserIdentity($_POST['username'], $_POST['password']);
             $identity->authenticate();
         }
         if ($identity->errorCode === UserIdentity::ERROR_NONE) {
             //$duration=$_POST['rememberme'] ? 3600*24*30 : 0; // 30 days
             $duration = 0;
             Yii::app()->user->login($identity);
             Yii::app()->user->login($identity, $duration);
             $this->redirect(Yii::app()->baseUrl . '/infrastructure/mylist');
         } else {
             if ($identity->errorCode === UserIdentity::ERROR_USERNAME_INVALID) {
                 $this->renderPartial('login', array('msgError' => "Invalid Username"));
             } else {
                 if ($identity->errorCode === UserIdentity::ERROR_PASSWORD_INVALID) {
                     $this->renderPartial('login', array('msgError' => "Invalid password", 'username' => $_POST['username']));
                 }
             }
         }
         //$this->renderPartial('login',array('msgError' => "none" ));
     } else {
         $this->renderPartial('login', array('msgError' => "none"));
     }
 }
开发者ID:phainamikaze,项目名称:miza,代码行数:27,代码来源:UserController.php


示例10: authenticate

 /**
  * Authenticates the password.
  * This is the 'authenticate' validator as declared in rules().
  */
 public function authenticate($attribute, $params)
 {
     if (!$this->hasErrors()) {
         // we only want to authenticate when no input errors
         $identity = new UserIdentity($this->username, $this->password);
         $identity->authenticate();
         switch ($identity->errorCode) {
             case UserIdentity::ERROR_NONE:
                 $duration = $this->rememberMe ? 3600 * 24 * 30 : 0;
                 // 30 days
                 Yii::app()->user->login($identity, $duration);
                 break;
                 #				case UserIdentity::ERROR_USERNAME_INVALID:
                 #					$this->addError('username','Username is incorrect.');
                 #					break;
             #				case UserIdentity::ERROR_USERNAME_INVALID:
             #					$this->addError('username','Username is incorrect.');
             #					break;
             case UserIdentity::ERROR_USER_NOT_ACTIVATED:
                 $this->addError('username', 'User is not activated');
                 break;
             default:
                 // UserIdentity::ERROR_PASSWORD_INVALID
                 $this->addError('password', 'Either your Username or Password is incorrect.');
                 $this->addError('username', '');
                 break;
         }
     }
 }
开发者ID:jessesiu,项目名称:GigaDBV3,代码行数:33,代码来源:LoginForm.php


示例11: init

 /**
  * Set default user states so the application won't crash
  * when trying to access these properies and they don't exist
  */
 public function init()
 {
     $cs = Yii::app()->clientScript;
     $baseUrl = $this->createFrontendUrl('/');
     $cs->registerCssFile($baseUrl . '/themes/boxomatic/admin/css/admin.css');
     $this->scriptLocations[Yii::app()->basePath . '/../public_html/themes/boxomatic/admin/'] = $this->createFrontendUrl('/') . '/themes/boxomatic/admin/';
     $this->nav_brand_label = CHtml::image('/themes/boxomatic/images/cog-leaf.png');
     if (!Yii::app()->user->hasState('user_id')) {
         Yii::app()->user->setState('user_id', false);
     }
     if (!Yii::app()->user->hasState('supplier_id')) {
         Yii::app()->user->setState('supplier_id', false);
     }
     if (!Yii::app()->user->hasState('shadow_id')) {
         Yii::app()->user->setState('shadow_id', false);
     }
     if (!Yii::app()->user->hasState('shadow_name')) {
         Yii::app()->user->setState('shadow_name', false);
     }
     //Test if the login key find the user and auto login.
     $key = Yii::app()->request->getParam('key');
     if ($key) {
         $User = User::model()->findByAttributes(array('auto_login_key' => $key), 'update_time > date_sub(NOW(), interval 7 day)');
         if ($User) {
             $identity = new UserIdentity($User->email, '');
             $identity->authenticate(false);
             Yii::app()->user->login($identity);
             $User->auto_login_key = '';
             $User->save(false);
         }
         //exit;
     }
 }
开发者ID:snapfrozen,项目名称:boxomatic,代码行数:37,代码来源:BoxomaticController.php


示例12: actionLogin

 /**
  * This is the action to handle login
  */
 public function actionLogin()
 {
     $data = $this->getInputAsJson();
     if (empty($data['username']) || empty($data['password'])) {
         $this->sendResponse(401, 'Please, fill up all username and password to login!');
     }
     // Authenticate user credentials
     $identity = new UserIdentity($data['username'], $data['password']);
     if ($identity->authenticate()) {
         Yii::app()->user->login($identity);
         $this->sendResponse(200, CJSON::encode(array('authenticated' => true)));
     } else {
         switch ($identity->errorCode) {
             case UserIdentity::ERROR_USERNAME_INVALID:
                 $error = 'Incorrect username';
                 break;
             case UserIdentity::ERROR_PASSWORD_INVALID:
                 $error = 'Incorrect password';
                 break;
             case UserIdentity::ERROR_USER_IS_DELETED:
                 $error = 'This user is deleted';
                 break;
         }
         $this->sendResponse(401, $error);
     }
 }
开发者ID:schlypel,项目名称:YiiBackboneBoilerplate,代码行数:29,代码来源:SiteController.php


示例13: init

 function init()
 {
     // MFM CController
     parent::init();
     $app = Yii::app();
     if (isset($_POST['_lang'])) {
         $app->language = $_POST['_lang'];
         $app->session['_lang'] = $app->language;
     } else {
         if (isset($app->session['_lang'])) {
             $app->language = $app->session['_lang'];
         }
     }
     //-----------------------------
     if (!Yii::app()->user->isGuest) {
         $identity = new UserIdentity(Yii::app()->user->username, Yii::app()->user->password);
         $identity->authenticate(false);
         if ($identity->errorCode != ERROR_NONE) {
             Yii::app()->user->logout();
             Yii::app()->user->setState('status', User::STATUS_GUEST);
             $this->redirect(Yii::app()->homeUrl);
         }
     } else {
         Yii::app()->user->setState('status', User::STATUS_GUEST);
     }
 }
开发者ID:smoothcoder,项目名称:DISCARDEDYiiblog,代码行数:26,代码来源:BaseController.php


示例14: change_pass

 public function change_pass($param, $options)
 {
     echo "<h3>change_pass</h3>";
     if (empty($this->{$param})) {
         return;
     }
     if ($this->hasErrors()) {
         return;
     }
     if (empty($this->new_pass)) {
         $this->addError("new_pass", "Введите новый пароль!");
         return;
     }
     if (!$this->validate(array("new_pass", "new_pass2"))) {
         return;
     }
     echo "<h3>check old pass</h3>";
     $ui = new UserIdentity(Yii::app()->user->login, $this->old_pass);
     if (!$ui->authenticate()) {
         $this->addError("old_pass", "Неверный пароль. Если вы не можете его вспомнить, вам <a href='/register/remind'>сюда</a>.");
     } else {
         echo "<p>check ok</p>";
         $this->pass = self::hashPass($this->new_pass);
     }
     echo "<h3>/change_pass</h3>";
 }
开发者ID:norayr,项目名称:notabenoid,代码行数:26,代码来源:UserSettings.php


示例15: authenticate

 /**
  * Authenticates the password.
  * This is the 'authenticate' validator as declared in rules().
  */
 public function authenticate($attribute, $params)
 {
     if (!$this->hasErrors()) {
         $identity = new UserIdentity($this->username, $this->password);
         $identity->authenticate();
         switch ($identity->errorCode) {
             case UserIdentity::ERROR_NONE:
                 $duration = $this->rememberMe ? Yii::app()->controller->module->rememberMeTime : 0;
                 Yii::app()->user->login($identity, $duration);
                 break;
             case UserIdentity::ERROR_EMAIL_INVALID:
                 $this->addError("username", UserModule::t("Correo incorrecto"));
                 break;
             case UserIdentity::ERROR_USERNAME_INVALID:
                 $this->addError("username", UserModule::t("Nombre de usuario incorrecto"));
                 break;
             case UserIdentity::ERROR_STATUS_NOTACTIV:
                 $this->addError("status", UserModule::t("Su cuenta no está activada"));
                 break;
             case UserIdentity::ERROR_STATUS_BAN:
                 $this->addError("status", UserModule::t("Su cuenta ha sido blockeada"));
                 break;
             case UserIdentity::ERROR_PASSWORD_INVALID:
                 $this->addError("password", UserModule::t("Contraseña incorrecta"));
                 break;
         }
     }
 }
开发者ID:alsvader,项目名称:hackbanero,代码行数:32,代码来源:UserLogin.php


示例16: authenticate

 /**
  * Authenticates the password.
  * This is the 'authenticate' validator as declared in rules().
  */
 public function authenticate($attribute, $params)
 {
     if (!$this->hasErrors()) {
         $identity = new UserIdentity($this->username, $this->password);
         $identity->authenticate();
         switch ($identity->errorCode) {
             case UserIdentity::ERROR_NONE:
                 $duration = $this->rememberMe ? 3600 * 24 * 30 : 0;
                 // 30 days
                 Yii::app()->user->login($identity, $duration);
                 break;
             case UserIdentity::ERROR_EMAIL_INVALID:
                 $this->addError("username", UserModule::t("Email is incorrect."));
                 break;
             case UserIdentity::ERROR_USERNAME_INVALID:
                 $this->addError("username", UserModule::t("Username is incorrect. Please make sure you are using the secondary login details provided in your email"));
                 break;
             case UserIdentity::ERROR_STATUS_NOTACTIV:
                 $this->addError("status", UserModule::t("You account is not activated."));
                 break;
             case UserIdentity::ERROR_STATUS_BAN:
                 $this->addError("status", UserModule::t("You account is blocked."));
                 break;
             case UserIdentity::ERROR_PASSWORD_INVALID:
                 $this->addError("password", UserModule::t("Password is incorrect."));
                 break;
             case UserIdentity::ERROR_SERVER_ERROR:
                 $this->addError("status", UserModule::t("There is a server error. Please contact support"));
                 break;
             default:
                 $this->addError("status", UserModule::t("KUCH TO GADABAD HAI"));
                 break;
         }
     }
 }
开发者ID:sudeeptalati,项目名称:AmicaEngineerPortal,代码行数:39,代码来源:UserLogin.php


示例17: actionRegistration

 /**
  * Registration user
  */
 public function actionRegistration()
 {
     $this->layout = '//layouts/login';
     $model = new RegistrationForm();
     // ajax validator
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'signup-form_id') {
         /* echo UActiveForm::validate($model);
            Yii::app()->end(); */
         $errors = CActiveForm::validate($model);
         echo $errors;
         Yii::app()->end();
     }
     if (Yii::app()->user->id) {
         $this->redirect('/');
     } else {
         $this->redirect('/login');
         if (isset($_POST['RegistrationForm'])) {
             $model->attributes = $_POST['RegistrationForm'];
             $model->verifyPassword = $model->password;
             if ($model->validate()) {
                 $soucePassword = $model->password;
                 $model->activkey = UsersModule::encrypting(microtime() . $model->password);
                 $model->password = UsersModule::encrypting($model->password);
                 $model->verifyPassword = UsersModule::encrypting($model->verifyPassword);
                 $model->status = Yii::app()->getModule('users')->activeAfterRegister ? User::STATUS_ACTIVE : User::STATUS_NOACTIVE;
                 if ($model->save()) {
                     Yii::app()->queue->subscribe($model->id, null, "User.{$model->id}");
                     if (Yii::app()->getModule('users')->sendActivationMail) {
                         $activation_url = $this->createAbsoluteUrl('/user/activation/activation', array("activkey" => $model->activkey, "email" => $model->email));
                         UsersModule::sendMail($model->email, UsersModule::t("You registered from {site_name}", array('{site_name}' => Yii::app()->name)), UsersModule::t("Please activate you account go to {activation_url}", array('{activation_url}' => $activation_url)));
                     }
                     // wellcome email
                     $subject = Yii::t('email', 'Welcome');
                     $message = Yii::t('email', 'Welcome to <a href="{url}">{catalog}</a>.', array('{url}' => $this->createAbsoluteUrl('/'), '{catalog}' => Yii::app()->name));
                     SendMail::send($model->email, $subject, $message, true);
                     if ((Yii::app()->getModule('users')->loginNotActiv || Yii::app()->getModule('users')->activeAfterRegister && Yii::app()->getModule('users')->sendActivationMail == false) && Yii::app()->getModule('users')->autoLogin) {
                         $identity = new UserIdentity($model->username, $soucePassword);
                         $identity->authenticate();
                         Yii::app()->user->login($identity, 0);
                         $this->redirect(Yii::app()->getModule('users')->returnUrl);
                     } else {
                         if (!Yii::app()->getModule('users')->activeAfterRegister && !Yii::app()->getModule('users')->sendActivationMail) {
                             Yii::app()->user->setFlash('registration', UsersModule::t("Thank you for your registration. Contact Admin to activate your account."));
                         } elseif (Yii::app()->getModule('users')->activeAfterRegister && Yii::app()->getModule('users')->sendActivationMail == false) {
                             Yii::app()->user->setFlash('registration', UsersModule::t("Thank you for your registration. Please {{login}}.", array('{{login}}' => CHtml::link(UsersModule::t('Login'), Yii::app()->getModule('users')->loginUrl))));
                         } elseif (Yii::app()->getModule('users')->loginNotActiv) {
                             Yii::app()->user->setFlash('registration', UsersModule::t("Thank you for your registration. Please check your email or login."));
                         } else {
                             Yii::app()->user->setFlash('registration', UsersModule::t("Thank you for your registration. Please check your email."));
                         }
                         $this->refresh();
                     }
                 }
             } else {
                 // var_dump($model->errors);die();
             }
         }
         $this->render('/user/registration', array('model' => $model));
     }
 }
开发者ID:Aplay,项目名称:myhistorypark_site,代码行数:63,代码来源:RegistrationController.php


示例18: run

 public function run()
 {
     // Parameters
     $username = $_REQUEST['popup_username'];
     $password = $_REQUEST['popup_password'];
     $rememberMe = $_REQUEST['popup_rememberMe'];
     if (isset($username)) {
         $identity = new UserIdentity($username, $password);
         $identity->authenticate();
         switch ($identity->errorCode) {
             case UserIdentity::ERROR_NONE:
                 $duration = $rememberMe ? 3600 * 24 * 30 : 0;
                 // 30 days
                 Yii::app()->user->login($identity, $duration);
                 $result["result"] = 0;
                 $result["message"] = Yii::t('amo', 'Login correct');
                 break;
             case UserIdentity::ERROR_USERNAME_INVALID:
                 $result["result"] = -1;
                 $result["message"] = Yii::t('amo', 'Username is not registered');
                 break;
             default:
                 // UserIdentity::ERROR_PASSWORD_INVALID
                 $result["result"] = -1;
                 $result["message"] = Yii::t('amo', 'Password is not valid');
                 break;
         }
     } else {
         $result["result"] = -1;
         $result["message"] = Yii::t('amo', 'No login info');
     }
     echo CJSON::encode($result);
     exit(0);
     // To avoid loggers append things to request
 }
开发者ID:CHILMEX,项目名称:amocasion,代码行数:35,代码来源:AjaxLoginAction.php


示例19: actionRegister

 public function actionRegister()
 {
     $user = new User('register');
     $profile = new Profile('register');
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'register') {
         $user->scenario = 'registerPlusComparePassword';
         echo CActiveForm::validate(array($user, $profile));
         Yii::app()->end();
     }
     if (isset($_POST['User'])) {
         $user->attributes = $_POST['User'];
         $user->password = md5($user->password);
         $user->password_repeat = md5($user->password_repeat);
         $user->user_type_id = 2;
         if ($user->save()) {
             if (isset($_POST['Profile'])) {
                 $profile->attributes = $_POST['Profile'];
                 $profile->birthday = $profile->b_year . "-" . $profile->b_month . "-" . $profile->b_day;
                 $profile->user_id = $user->id;
                 $profile->save();
                 $identity = new UserIdentity($user->login, $user->password);
                 $identity->authenticate();
                 Yii::app()->user->login($identity, 86400 * 7);
             }
             $this->redirect(array('index/index'));
         }
     }
     $this->render("registration", array('user' => $user, 'profile' => $profile));
 }
开发者ID:vetalded,项目名称:homelibrary16mbcom,代码行数:29,代码来源:IndexController.php


示例20: actionLogin

 public function actionLogin()
 {
     if (Yii::app()->user->isGuest) {
         $user = new CatalogUsersAuthConsole();
         if (!empty($_POST["CatalogUsersAuthConsole"])) {
             Yii::app()->page->title = "Авторизация";
             $user->setAttributes($_POST["CatalogUsersAuthConsole"]);
             if ($user->validate()) {
                 $identity = new UserIdentity($user->email, $user->password);
                 $identity->authenticate();
                 if (empty($identity->errorMessage)) {
                     Yii::app()->user->login($identity);
                     // Опрпделяем первый вход человека в личны кабинет
                     if (!empty(Yii::app()->session['redirect'])) {
                         $redirectUrl = Yii::app()->session['redirect'];
                         Yii::app()->session['redirect'] = "";
                         $this->redirect($redirectUrl);
                     }
                     $this->redirect($this->createUrl("/console"));
                 } else {
                     $user->addError("Ошибка авторизации", $identity->errorMessage);
                 }
             }
         }
         $this->render('login', array('form' => $user));
     } else {
         Yii::app()->page->title = "Административный кабинет";
         $this->render("room", array());
     }
 }
开发者ID:bogiesoft,项目名称:yii-travel,代码行数:30,代码来源:DefaultController.php



注:本文中的UserIdentity类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP UserInfo类代码示例发布时间:2022-05-23
下一篇:
PHP UserHelper类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap