public function actionLogin() { $formLogin = new LoginForm(); if (isset($_POST['ajax']) && $_POST['ajax'] === 'login-form') { var_dump($_POST); die; echo CActiveForm::validate($model); Yii::app()->end(); } if (isset($_POST['LoginForm'])) { $formLogin->attributes = $_POST['LoginForm']; if ($formLogin->validate() && $formLogin->login()) { $idSesion = Yii::app()->user->id; $objusuario = new Usuarios(); $usuario = $objusuario->findByPk($idSesion); switch ($usuario->roles_id) { case '1': # Redirecciona al perfil del Usuario registrado break; case '2' or '3': $this->redirect(array('propuestas/listar')); break; default: $this->redirect(array('site/login')); break; } } } $this->render('login', array('model' => $formLogin)); }
/** * This is the action to handle external exceptions. */ public function actionLogin() { if (!Yii::app()->user->isGuest) { $this->redirect('/member/index.html'); } $this->pageTitle = "登录中心 - " . Yii::app()->name; if (isset($_POST['username'])) { $status = array(); if (!isset($_POST['username']) || !isset($_POST['password'])) { $status = array('status' => 0, "info" => '用户名或者密码错误!'); } else { Yii::import("application.models.form.LoginForm", true); $loginform = new LoginForm(); if (!isset($_POST['rememberMe'])) { $_POST['rememberMe'] = false; } $loginform->setAttributes(array('username' => $_POST['username'], 'password' => $_POST['password'], 'rememberMe' => $_POST['rememberMe'])); if ($loginform->validate() && $loginform->login()) { $status = array('status' => 1, "info" => '登录'); } else { $status = array('status' => 0, "info" => '用户名或者密码错误!'); } } echo json_encode($status); Yii::app()->end(); } $this->render('html5_login'); }
public function run() { if (Yii::app()->user->isAuthenticated()) { $this->controller->redirect(Url::redirectUrl(Yii::app()->getUser()->getReturnUrl())); } /** * Если было совершено больше 3х попыток входа * в систему, используем сценарий с капчей: **/ $badLoginCount = Yii::app()->authenticationManager->getBadLoginCount(Yii::app()->getUser()); $module = Yii::app()->getModule('user'); $scenario = $badLoginCount > (int) $module->badLoginCount ? LoginForm::LOGIN_LIMIT_SCENARIO : ''; $form = new LoginForm($scenario); if (Yii::app()->getRequest()->getIsPostRequest() && !empty($_POST['LoginForm'])) { $form->setAttributes(Yii::app()->getRequest()->getPost('LoginForm')); if ($form->validate() && Yii::app()->authenticationManager->login($form, Yii::app()->getUser(), Yii::app()->getRequest())) { Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('UserModule.user', 'You authorized successfully!')); if (Yii::app()->getUser()->isSuperUser() && $module->loginAdminSuccess) { $redirect = $module->loginAdminSuccess; } else { $redirect = empty($module->loginSuccess) ? Yii::app()->getBaseUrl() : $module->loginSuccess; } $redirect = Yii::app()->getUser()->getReturnUrl($redirect); Yii::app()->authenticationManager->setBadLoginCount(Yii::app()->getUser(), 0); $this->controller->redirect(Url::redirectUrl($redirect)); } else { $form->addError('email', Yii::t('UserModule.user', 'Email or password was typed wrong!')); Yii::app()->authenticationManager->setBadLoginCount(Yii::app()->getUser(), $badLoginCount + 1); } } $this->controller->render($this->id, array('model' => $form)); }
/** * Executes the log-in attempt using the parameters passed. If * the log-in succeeeds, it attaches a cookie to the session * and outputs the user id, username, and session token. If a * log-in fails, as the result of a bad password, a nonexistant * user, or any other reason, the host is cached with an expiry * and no log-in attempts will be accepted until that expiry * is reached. The expiry is $this->mLoginThrottle. * * @access public */ public function execute() { $name = $password = $domain = null; extract($this->extractRequestParams()); $result = array(); // Make sure noone is trying to guess the password brut-force $nextLoginIn = $this->getNextLoginTimeout(); if ($nextLoginIn > 0) { $result['result'] = 'NeedToWait'; $result['details'] = "Please wait {$nextLoginIn} seconds before next log-in attempt"; $result['wait'] = $nextLoginIn; $this->getResult()->addValue(null, 'login', $result); return; } $params = new FauxRequest(array('wpName' => $name, 'wpPassword' => $password, 'wpDomain' => $domain, 'wpRemember' => '')); // Init session if necessary if (session_id() == '') { wfSetupSession(); } $loginForm = new LoginForm($params); switch ($loginForm->authenticateUserData()) { case LoginForm::SUCCESS: global $wgUser, $wgCookiePrefix; $wgUser->setOption('rememberpassword', 1); $wgUser->setCookies(); $result['result'] = 'Success'; $result['lguserid'] = $_SESSION['wsUserID']; $result['lgusername'] = $_SESSION['wsUserName']; $result['lgtoken'] = $_SESSION['wsToken']; $result['cookieprefix'] = $wgCookiePrefix; $result['sessionid'] = session_id(); break; case LoginForm::NO_NAME: $result['result'] = 'NoName'; break; case LoginForm::ILLEGAL: $result['result'] = 'Illegal'; break; case LoginForm::WRONG_PLUGIN_PASS: $result['result'] = 'WrongPluginPass'; break; case LoginForm::NOT_EXISTS: $result['result'] = 'NotExists'; break; case LoginForm::WRONG_PASS: $result['result'] = 'WrongPass'; break; case LoginForm::EMPTY_PASS: $result['result'] = 'EmptyPass'; break; default: ApiBase::dieDebug(__METHOD__, 'Unhandled case value'); } if ($result['result'] != 'Success') { $result['wait'] = $this->cacheBadLogin(); $result['details'] = "Please wait " . self::THROTTLE_TIME . " seconds before next log-in attempt"; } // if we were allowed to try to login, memcache is fine $this->getResult()->addValue(null, 'login', $result); }
public function initialize(sfEventDispatcher $dispatcher, sfStorage $storage, $options = array()) { parent::initialize($dispatcher, $storage, $options); $env = sfContext::getInstance()->getConfiguration()->getEnvironment(); if ($env != 'test') { $this->checkPermissions(); $this->resetPasswordCheck(); // here? $this->checkDatabase(); $this->checkHtaccess(); $this->performTests(); } $request = sfContext::getInstance()->getRequest(); if (!$this->isAuthenticated()) { if ($request->getPostParameter('password') == '' && $request->getCookie($this->cookie_name) != '' && $request->getMethod() != sfRequest::POST) { $params = array(); $params['password'] = $request->getCookie($this->cookie_name); $form = new LoginForm($this, true, array(), array(), false); // no csrf $form->bind($params); if ($form->isValid()) { $this->setAuthenticated(true); } } } }
public function executeDologin(sfWebRequest $request) { $form = new LoginForm(); $form->bind($this->getRequestParameter('credentials')); if ($form->isValid()) { $credentials = $request->getParameter('credentials'); $login = $credentials['login']; $user = UserTable::getUserFromLogin($login); ## Store array of allowed sectionIds that can be accessed! $sectionIdsArray = Doctrine_Core::getTable('Program')->getProgramsByDepartmentId($user->getDepartmentId()); // set the session correctly $this->getUser()->setAuthenticated(true); $this->getUser()->setAttribute('userId', $user->getId()); $this->getUser()->setAttribute('departmentId', $user->getDepartmentId()); $this->getUser()->setAttribute('departmentName', $user->getDepartment()); $this->getUser()->setAttribute('sectionIds', array_keys($sectionIdsArray)); $this->getUser()->setAttribute('credential', $user->getPrivilege()); ##Do Logging!! $newLog = new AuditLog(); $action = 'User has logged into Student Record Management System'; $newLog->addNewLogInfo($this->getUser()->getAttribute('userId'), $action); $this->getUser()->setFlash('notice', 'Welcome' . ' ' . $user->getFirstName()); //$this->redirect('filter/show?id='.$user->getId()); $this->redirect('programsection/index'); } else { // give the form again $this->form = $form; $this->setTemplate('login'); } }
public function execute($par) { global $wgUser, $wgCommandLineMode, $wgLang, $wgOut, $wrAdminUserName; if (wfReadOnly()) { $wgOut->readOnlyPage(); return; } if ($wgUser->isLoggedIn()) { if ($wgUser->getName() == $wrAdminUserName) { $user = User::newFromName($par); } else { $user = $wgUser; } $msg = ''; if ($user->getID() > 0) { $user->setOption('enotifwatchlistpages', 0); $user->setOption('enotifusertalkpages', 0); $user->setOption('enotifminoredits', 0); $user->setOption('disablemail', 1); $user->saveSettings(); } else { $msg = $user->getName() . ' not found'; } $this->show($msg); } else { if (!$wgCommandLineMode && !isset($_COOKIE[session_name()])) { User::SetupSession(); } $request = new FauxRequest(array('returnto' => $wgLang->specialPage('Unsubscribe'))); require_once 'includes/SpecialUserlogin.php'; $form = new LoginForm($request); $form->mainLoginForm("You need to log in to unsubscribe<br/><br/>", ''); } }
public function loginAction() { $form = new LoginForm(); $request = $this->getRequest(); if ($request->isPost() && $request->getPost('login') == 'Login') { $post = $request->getPost(); if ($form->isValid($post)) { $result = $this->_user->login($post['user'], $post['password']); //print_r($result); switch ($result) { case User::OK: $this->view->loginMsg = self::LOG_OK; $this->_redirect('/'); break; case User::BAD: $this->view->loginMsg = self::LOG_BAD; break; case User::BLOCK: $this->view->loginMsg = self::LOG_BLOCK; break; } } } $this->view->form = $form; }
/** * Login action */ public function actionindex() { $model = new LoginForm(); if (isset($_POST['LoginForm'])) { $model->attributes = $_POST['LoginForm']; if ($model->validate()) { // Login $identity = new InternalIdentity($model->email, $model->password); if ($identity->authenticate()) { // Member authenticated, Login Yii::app()->user->setFlash('success', Yii::t('login', 'Thanks. You are now logged in.')); Yii::app()->user->login($identity, Yii::app()->params['loggedInDays'] * 60 * 60 * 24); } // Redirect $this->redirect('index/index'); } } // Load facebook Yii::import('ext.facebook.facebookLib'); $facebook = new facebookLib(array('appId' => Yii::app()->params['facebookappid'], 'secret' => Yii::app()->params['facebookapisecret'], 'cookie' => true, 'disableSSLCheck' => false)); facebookLib::$CURL_OPTS[CURLOPT_CAINFO] = Yii::getPathOfAlias('ext.facebook') . '/ca-bundle.crt'; // Facebook link $facebookLink = $facebook->getLoginUrl(array('req_perms' => 'read_stream,email,offline_access', 'next' => Yii::app()->createAbsoluteUrl('/login/facebooklogin', array('lang' => false)), 'display' => 'popup')); $this->render('index', array('model' => $model, 'facebookLink' => $facebookLink, 'facebook' => $facebook)); }
public function actionLogout() { $actionFirst = Yii::app()->user->actionFirst; if ($actionFirst == 'admin') { $linkFirst = Yii::app()->user->linkFirst; $username = Yii::app()->user->usernameFirst; $password = Yii::app()->user->passwordFirst; $this->f_logout(); $model = new LoginForm(); $model->username = $username; $model->password = $password; $model->linkFirst = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null; $model->actionFirst = null; $model->usernameFirst = null; $model->passwordFirst = null; $model->flagStoreLogin = null; if ($model->loginWithRole()) { if ($linkFirst != null) { $this->redirect($linkFirst); } else { $this->redirect(array('store/index')); } } else { $this->redirect(array('site/login')); } } $this->redirect(Yii::app()->baseUrl . '/admin/site/logout'); }
/** * Displays the login page */ public function actionLogin() { $model = new LoginForm(); // if it is ajax validation request /* if (isset($_POST['ajax']) && $_POST['ajax'] === 'login-form') { echo CActiveForm::validate($model); Yii::app()->end(); } */ // collect user input data if (isset($_POST['LoginForm'])) { $model->attributes = $_POST['LoginForm']; // validate user input and redirect to the previous page if valid if ($model->validate() && $model->login()) { /* Simpan theme ke cookies */ $user = User::model()->findByPk(Yii::app()->user->id); $theme = Theme::model()->findByPk($user->theme_id); $theme->toCookies(); $this->redirect(Yii::app()->user->returnUrl); } } // display the login form $this->render('login', array('model' => $model)); }
/** * Displays the login page */ public function actionLogin() { if (isset($_REQUEST['email'])) { $model = new LoginForm(); // echo $_REQUEST['email']."<br>"; // echo $_REQUEST['password']."<br>"; $model->username = $_REQUEST['email']; $model->password = $_REQUEST['password']; // validate user input and redirect to the previous page if valid if ($model->validate() && $model->login()) { $user = User::model()->findByPk(Yii::app()->user->id); $user->last_login = date('Y-m-d h:i:s'); $user->scenario = 'login'; if ($user->save()) { echo $user->level; } else { print_r($user->getErrors()); } // echo "succesfull"; } else { echo "failed"; // print_r($model->getErrors()); } } else { echo "ga post ke login form"; } }
public function actionLogin() { //echo 'Yuan want to login system!'; //通过控制器来调用视图 //renderPartial()调用视图,不渲染布局,render可以 //$this->renderPartial('login'); if (!Yii::app()->user->isGuest) { $this->redirect(array('user/home', 'uid' => Yii::app()->user->id)); } //创建登录模型对象 $user_login = new LoginForm(); if (isset($_POST['LoginForm'])) { //收集登录表单信息 $user_login->attributes = $_POST['LoginForm']; //持久化用户信息 session,login()方法 //校验通过 validate()方法 if ($user_login->validate() && $user_login->login()) { //$this->redirect(Yii::app()->user->returnUrl);//session 储存,开始 //$this->redirect("./index.php?r=user/home&id=$id"); //$this->redirect(Yii::app()->request->urlReferrer); $this->redirect(array('user/home', 'uid' => Yii::app()->user->id)); } } $this->render('login', array('user_login' => $user_login)); }
public function run() { if (Yii::app()->user->isAuthenticated()) { $this->controller->redirect(Yii::app()->user->returnUrl); } /** * Если было совершено больше 3х попыток входа * в систему, используем сценарий с капчей: **/ $badLoginCount = Yii::app()->authenticationManager->getBadLoginCount(Yii::app()->user); //@TODO 3 вынести в настройки модуля $scenario = $badLoginCount > 3 ? 'loginLimit' : ''; $form = new LoginForm($scenario); $module = Yii::app()->getModule('user'); if (Yii::app()->getRequest()->getIsPostRequest() && !empty($_POST['LoginForm'])) { $form->setAttributes(Yii::app()->request->getPost('LoginForm')); if ($form->validate() && Yii::app()->authenticationManager->login($form, Yii::app()->user, Yii::app()->request)) { Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('UserModule.user', 'You authorized successfully!')); $module->onSuccessLogin(new CModelEvent($this->controller, array('loginForm' => $form))); if (Yii::app()->user->isSuperUser() && $module->loginAdminSuccess) { $redirect = array($module->loginAdminSuccess); } else { $redirect = empty($module->loginSuccess) ? Yii::app()->baseUrl : $module->loginSuccess; } Yii::app()->authenticationManager->setBadLoginCount(Yii::app()->user, 0); $this->controller->redirect($redirect); } else { $form->addError('hash', Yii::t('UserModule.user', 'Email or password was typed wrong!')); Yii::app()->authenticationManager->setBadLoginCount(Yii::app()->user, $badLoginCount + 1); $module->onErrorLogin(new CModelEvent($this->controller, array('loginForm' => $form))); } } $this->controller->render($this->id, array('model' => $form)); }
/** * Visualiza la pagina de autenticacion de usuario */ public function actionAutenticar() { $this->showSeeker = true; $model = new LoginForm(); if (isset($_POST['LoginForm'])) { $model->attributes = $_POST['LoginForm']; if ($model->validate()) { if (Yii::app()->session[Yii::app()->params->sesion['redireccionAutenticacion']] == 'null') { $this->redirect(Yii::app()->homeUrl); } else { $redirect = Yii::app()->session[Yii::app()->params->sesion['redireccionAutenticacion']]; Yii::app()->session[Yii::app()->params->sesion['redireccionAutenticacion']] = 'null'; $this->redirect($redirect); } //echo "--URL: " . Yii::app()->request->urlReferrer; //$this->redirect(Yii::app()->request->urlReferrer); //$this->redirect(Yii::app()->user->returnUrl); } } else { if (!isset(Yii::app()->session[Yii::app()->params->sesion['redireccionAutenticacion']]) || Yii::app()->session[Yii::app()->params->sesion['redireccionAutenticacion']] == 'null') { Yii::app()->session[Yii::app()->params->sesion['redireccionAutenticacion']] = Yii::app()->request->urlReferrer == null ? 'null' : Yii::app()->request->urlReferrer; } } $this->render('autenticar', array('model' => $model)); }
public function execute($request) { if ($request->isMethod(sfWebRequest::POST)) { $loginForm = new LoginForm(); $csrfToken = $request->getParameter('_csrf_token'); if ($csrfToken != $loginForm->getCSRFToken()) { $this->getUser()->setFlash('message', __('Csrf token validation failed'), true); $this->forward('auth', 'retryLogin'); } $username = $request->getParameter('txtUsername'); $password = $request->getParameter('txtPassword'); $additionalData = array('timeZoneOffset' => $request->getParameter('hdnUserTimeZoneOffset', 0)); try { $success = $this->getAuthenticationService()->setCredentials($username, $password, $additionalData); if ($success) { $this->getBeaconCommunicationService()->setBeaconActivation(); $this->getLoginService()->addLogin(); $this->redirect($this->getHomePageService()->getPathAfterLoggingIn($this->getContext())); } else { $this->getUser()->setFlash('message', __('Invalid credentials'), true); $this->forward('auth', 'retryLogin'); } } catch (AuthenticationServiceException $e) { $this->getUser()->setFlash('message', $e->getMessage(), false); $this->forward('auth', 'login'); } } return sfView::NONE; }
public function actionRegister() { $model = new User('register'); $provinces = Province::model()->findAll(); $provinces = CHtml::listData($provinces, 'idProvince', 'name'); $cities = array(); $districts = array(); if (isset($_POST['User'])) { $model->attributes = $_POST['User']; if ($model->createUser()) { //Log in the new user $modelLoginForm = new LoginForm(); $modelLoginForm->username = $model->username; $modelLoginForm->password = $model->conf_password; //because password has been md5 if ($modelLoginForm->login()) { $this->redirect(Yii::app()->user->returnUrl); } } if (isset($model->idProvince)) { $cities = City::model()->findAllByAttributes(array('idProvince' => $model->idProvince)); $cities = CHtml::listData($cities, 'idCity', 'name'); } if (isset($model->idCity)) { $districts = District::model()->findAllByAttributes(array('idCity' => $model->idCity)); $districts = CHtml::listData($districts, 'idDistrict', 'name'); } } $this->render('register', array('model' => $model, 'provinces' => $provinces, 'cities' => $cities, 'districts' => $districts)); }
public function execute($par) { global $wgUser, $wgCommandLineMode, $wgLang, $wgOut, $wrAdminUserName; if (wfReadOnly()) { $wgOut->readOnlyPage(); return; } if ($wgUser->isLoggedIn() && $wgUser->getName() == $wrAdminUserName) { $pieces = explode('/', $par); if (count($pieces) > 1 && strlen($pieces[1]) == 8) { $pieces[1] .= '000000'; } $user = User::newFromName($pieces[0]); $msg = ''; if (count($pieces) == 2 && $user->getID() > 0 && strlen($pieces[1]) == 14) { $user->setOption('wrnoads', $pieces[1]); $user->saveSettings(); } else { $msg = $pieces[0] . ' not found or date incorrect'; } $this->show($msg); } else { if (!$wgCommandLineMode && !isset($_COOKIE[session_name()])) { User::SetupSession(); } $request = new FauxRequest(array('returnto' => $wgLang->specialPage('NoAds'))); $form = new LoginForm($request); $form->mainLoginForm("You need to log in<br/><br/>", ''); } }
public function renderContent() { if (Yii::app()->user->isMember) { $this->render('bank'); } else { $model = new LoginForm(); // collect user input data if (isset($_POST['LoginForm'])) { $model->attributes = $_POST['LoginForm']; // validate user input and redirect to the previous page if valid //if($model->validate() && $model->login()) if ($model->validate()) { switch (Yii::app()->user->role_id) { case ROLE_MEMBER: Yii::app()->controller->redirect(Yii::app()->createAbsoluteUrl('member')); break; case ROLE_ADMIN: Yii::app()->controller->redirect(Yii::app()->createAbsoluteUrl('admin/login')); break; default: Yii::app()->controller->redirect(Yii::app()->createAbsoluteUrl('member')); } Yii::app()->end(); } } // display the login form $this->render('form', array('model' => $model)); } }
public function actionSignup() { $model = new User(); // uncomment the following code to enable ajax-based validation /* if(isset($_POST['ajax']) && $_POST['ajax']==='user-signup-form') { echo CActiveForm::validate($model); Yii::app()->end(); } */ if (isset($_POST['User'])) { $model->attributes = $_POST['User']; if ($model->validate()) { $login = new LoginForm(); $login->username = $model->email; $login->password = $model->password; $model->save(false); if ($login->validate(array('username', 'password')) && $login->login()) { $this->redirect(Yii::app()->user->returnUrl); } else { echo "Email:" . $model->email; echo "Password:" . $model->password; $this->render('login', array('model' => $login)); return; } // form inputs are valid, do something here } } $this->render('signup', array('model' => $model)); }
/** * Displays the login page */ public function actionLogin() { /** * Авторизация по токену для восстановления пароля */ if ($recoveryPasswordToken = Yii::app()->request->getParam('token')) { if ($user = CmsUser::getByRecoveryPasswordToken($recoveryPasswordToken)) { $log = new LoginForm(); $log->username = $user->username; $log->password = $user->password; $log->login(); $this->redirect($this->createAbsoluteUrl('UserPersonal/index', array('id' => $user->id))); } } $service = Yii::app()->request->getQuery('service'); if (isset($service)) { $authIdentity = Yii::app()->eauth->getIdentity($service); $authIdentity->redirectUrl = Yii::app()->user->returnUrl; $authIdentity->cancelUrl = $this->createAbsoluteUrl('site/login'); if ($authIdentity->authenticate()) { $identity = new ServiceUserIdentity($authIdentity); // Успешный вход if ($identity->authenticate()) { Yii::app()->user->login($identity); // Специальный редирект с закрытием popup окна $authIdentity->redirect(); } else { // Закрываем popup окно и перенаправляем на cancelUrl $authIdentity->cancel(); } } $this->redirect(array('site/login')); } //авторизация с помошью соц сетей $model = new LoginForm(); // if it is ajax validation request if (isset($_POST['ajax']) && $_POST['ajax'] === 'login-form') { echo CActiveForm::validate($model); Yii::app()->end(); } // collect user input data if (isset($_POST['LoginForm'])) { $model->attributes = $_POST['LoginForm']; // validate user input and redirect to the previous page if valid // $model1=CmsUser::model()->findByAttributes(array('username'=>$model->username)); $model_set = CmsSetting::model()->findByPk(1); if ($model_set->podtv_email == 1) { $user = CmsUser::model()->findByAttributes(array('username' => $model->username)); $user->sendRecoveryPasswordMessage(); $this->render('login', array('model' => $model, 'flag' => true)); Yii::app()->end(); } else { if ($model->validate() && $model->login()) { $this->redirect(array('UserPersonal/index', 'id' => Yii::app()->user->id)); } } } // display the login form $this->render('login', array('model' => $model)); }
/** * */ public function run() { $module = Yii::app()->getModule('user'); if (false === Yii::app()->getUser()->getIsGuest()) { $this->getController()->redirect(\yupe\helpers\Url::redirectUrl($module->loginSuccess)); } $badLoginCount = Yii::app()->authenticationManager->getBadLoginCount(Yii::app()->getUser()); $scenario = $badLoginCount >= (int) $module->badLoginCount ? LoginForm::LOGIN_LIMIT_SCENARIO : ''; $form = new LoginForm($scenario); if (Yii::app()->getRequest()->getIsPostRequest() && !empty($_POST['LoginForm'])) { $form->setAttributes(Yii::app()->getRequest()->getPost('LoginForm')); if (Yii::app()->authenticationManager->login($form, Yii::app()->getUser(), Yii::app()->getRequest())) { Yii::app()->getUser()->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('UserModule.user', 'You authorized successfully!')); if (Yii::app()->getUser()->isSuperUser() && $module->loginAdminSuccess) { $redirect = [$module->loginAdminSuccess]; } else { $redirect = empty($module->loginSuccess) ? Yii::app()->getBaseUrl() : [$module->loginSuccess]; } $redirect = Yii::app()->getUser()->getReturnUrl($redirect); Yii::app()->authenticationManager->setBadLoginCount(Yii::app()->getUser(), 0); $this->getController()->redirect($redirect); } else { $form->addError('email', Yii::t('UserModule.user', 'Email or password was typed wrong!')); Yii::app()->authenticationManager->setBadLoginCount(Yii::app()->getUser(), $badLoginCount + 1); } } $this->getController()->render($this->id, ['model' => $form]); }
public function actionLogin() { if (isset($_POST['token'])) { $this->networkLogin(); } $this->layout = null; $this->breadCrumbs = array('Управление сайтом' => array('/users/default/siteManagment')); $form = new LoginForm(); if (isset($_POST['LoginForm'])) { $form->attributes = $_POST['LoginForm']; if ($form->validate()) { $backUrl = $form->getBackUrl(); if (Yii::app()->getRequest()->getIsAjaxRequest()) { echo CHtml::script("document.location='" . $backUrl . "'"); return; } else { $this->redirect($backUrl); } } } if (Yii::app()->getRequest()->getIsAjaxRequest()) { $this->renderPartial('form/login', array('form' => $form, 'backUrl' => $backurl)); } else { $this->render('login', array('user' => $form, 'backUrl' => $backurl)); } }
/** * Login action, detect if is a valid or invalid user */ public function loginAction() { $form = new LoginForm(); if ($this->request->isPost()) { if ($form->isValid($this->request->getPost()) != false) { $password = $this->request->getPost('password'); //Find the username and check if this is active into the application $user = User::findFirst(array("username = :username: AND active = 1", 'bind' => array('username' => strtolower($this->request->getPost('username', 'striptags'))))); // successfully find if ($user && $this->security->checkHash($password, $user->password)) { //Sent the user to set into the application $this->auth->setAccess($user); //Remember me: If is diferent to false assign a token to the user if ($this->request->getPost('remember') != "false") { $user->assign(array('token' => $this->request->getPost('remember'))); if (!$user->save()) { $this->flash->error($user->getMessages()); } } return $this->response->redirect('dashboard'); } else { $form->addFormMessages('username', 'Username name is invalid or not has been activated'); $form->addFormMessages('password', 'information does not match'); } } } $this->view->form = $form; }
public function actionLogin() { $baseUrl = Yii::app()->homeUrl; $baseUrl = Yii::app()->request->hostInfo . $baseUrl; if (Yii::app()->user->isGuest) { $model = new LoginForm(); if (Yii::app()->request->isPostRequest) { $model->attributes = $_POST['LoginForm']; // validate user input and redirect to the previous page if valid if ($model->validate() && $model->login()) { $this->redirect(Yii::app()->user->returnUrl); } else { $error = $model->getErrorCode(); //var_dump($error);exit; if ($error == 201) { echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'; echo "<h2 style='text-align:center'>Tài khoản của bạn đã bị khóa. Liên hệ TrangPTK để kích hoạt lại.({$error})</h2>"; exit; } } } // display the login form $this->render('login', array('model' => $model)); } else { $this->redirect('/'); } }
function submit_OTP($user_id, $user_name) { global $wgRequest, $wgOut, $wgUser; $otp_DB = ""; $attempts = 0; # When OTP button is pressed we we check if the OTP is set on DB. if ($wgRequest->getCheck('clickBotOTP')) { SpecialLatch::accDB_useraccid($user_id, $user_id, $acc_id, $otp_DB, $attempts); # CSRF protection if (!$wgUser->matchEditToken($wgRequest->getVal('token'))) { return; } else { # If it's correct we set again the correct user name to session and redirect to the main page if ($otp_DB == $wgRequest->getText('txt_OTP')) { $wgRequest->setSessionData('wsUserName', $user_name); $fullURL = $wgRequest->getRequestURL(); $urlMainPage = explode("?", $fullURL); $wgOut->redirect($urlMainPage[0]); } else { if ($attempts < 2) { SpecialLatch::updDB_useraccid($user_id, $acc_id, $otp_DB, $attempts + 1); $wgOut->addWikiText(wfMsg('latch-OTP-error')); } else { $wgUser->logout(); $wgOut->clearHTML(); $specialUserlogin = new LoginForm(); $specialUserlogin->load(); $error = $specialUserlogin->mAbortLoginErrorMsg ?: 'wrongpassword'; $specialUserlogin->mainLoginForm($specialUserlogin->msg($error)->text()); } } } } }
/** * Logs in the user using the given username and password in the model. * @return boolean whether login is successful */ public function save() { $user = new Users(); $user->setAttributes($this->attributes); $user->setAttribute("password", BaseTool::ENPWD($this->password)); if ($user->validate() && $user->save()) { $accountarray = array('user_id' => Yii::app()->db->getLastInsertID(), 'total' => 0, 'use_money' => 0, 'no_use_money' => 0, 'newworth' => 0); $newAccount = new Account(); $newAccount->setAttributes($accountarray); $newAccount->save(); //发送邮件 $activecode = BaseTool::getActiveMailCode($this->username); $message = MailTemplet::getActiveEmail($this->username, $activecode); $mail = Yii::app()->Smtpmail; $mail->SetFrom(Yii::app()->params['adminEmail']); $mail->Subject = "好帮贷测试邮件"; $mail->MsgHTML($message); $mail->AddAddress($this->email); if ($mail->Send()) { $user->updateAll(array("regtaken" => $activecode, "regativetime" => time() + 60 * 60), "username=:username", array(":username" => $this->username)); } Yii::import("application.models.form.LoginForm", true); $loginform = new LoginForm(); $loginarray = array('rememberMe' => false, 'username' => $this->username, 'password' => $this->password); $loginform->setAttributes($loginarray); if ($loginform->validate() && $loginform->login()) { } return true; } else { $usererror = $user->errors; $this->addError("username", current(current($usererror))); return false; } }
public function init() { Controller::initParams(); // this method is called when the module is being created // you may place code here to customize the module or the application Yii::app()->setComponent('bootstrap', array('class' => 'ext.bootstrap.components.Bootstrap', 'responsiveCss' => true)); Yii::setPathOfAlias('bootstrap', dirname(__FILE__) . DIRECTORY_SEPARATOR . '../../extensions/bootstrap'); Yii::app()->bootstrap->init(); // import the module-level models and components $this->setImport(array('admin.models.*', 'admin.components.*')); Yii::app()->setComponents(array('user' => array('class' => 'AdminUser', 'loginUrl' => Yii::app()->createAbsoluteUrl('admin/login'), 'allowAutoLogin' => true)), true); $this->layout = 'application.modules.admin.views.layouts.column1'; if (Yii::app()->params['STORE_OFFLINE'] == '-1') { die('Admin Panel unavailable due to account suspension.'); } if (isset($_POST['url']) && isset($_POST['password'])) { $model = new LoginForm(); if ($model->loginLightspeed($_POST['user'], $_POST['password'])) { Yii::app()->getRequest()->redirect(Yii::app()->createUrl("/admin")); } else { die("You have an invalid password set in your eCommerce options. Cannot continue."); } } if (!Yii::app()->user->isGuest) { if (Yii::app()->user->shouldLogOut()) { Yii::app()->user->logout(false); } } _xls_set_conf('ADMIN_PANEL', date("Y-m-d H:i:s")); parent::init(); }
/** * Main execution point */ function execute($par = '') { global $wgUser, $wgAuth, $wgOut, $wgRequest; if (!$wgAuth->allowPasswordChange()) { $this->error(wfMsg('resetpass_forbidden')); return; } if ($this->mName === null && !$wgRequest->wasPosted()) { $this->error(wfMsg('resetpass_missing')); return; } if ($wgRequest->wasPosted() && $wgUser->matchEditToken($wgRequest->getVal('token'))) { $newpass = $wgRequest->getVal('wpNewPassword'); $retype = $wgRequest->getVal('wpRetype'); try { $this->attemptReset($newpass, $retype); $wgOut->addWikiText(wfMsg('resetpass_success')); $data = array('action' => 'submitlogin', 'wpName' => $this->mName, 'wpPassword' => $newpass, 'returnto' => $wgRequest->getVal('returnto')); if ($wgRequest->getCheck('wpRemember')) { $data['wpRemember'] = 1; } $login = new LoginForm(new FauxRequest($data, true)); $login->execute(); return; } catch (PasswordError $e) { $this->error($e->getMessage()); } } $this->showForm(); }
public function actionTac_vu_khach() { $dangtin = new LoginForm(); $khachhang = new Khachhang(); $form = new CForm('application.views.admin.tac_vu_khach.form_tac_vu_khach', $khachhang); $khachhang->setScenario('dang_tin_khach'); if ($form->submitted('dangtinkhach') && $form->validate()) { $id = $khachhang->idkhach; $arry = explode("_", $id); $username = $arry[0]; if (isset($arry[1])) { $id = $arry[1]; if ($user = Khachhang::model()->TTkhach($id, $username)) { $dangtin->username = $user['ten_dang_nhap']; $dangtin->password = $user['password']; $dangtin->_identity = new UserIdentity($dangtin->username, $dangtin->password); $dangtin->_identity->authenticate(); $dangtin->login(); $this->redirect(Yii::app()->request->baseUrl . '/dang-tin'); } else { $this->__message = "Nhập sai id khách hàng!"; } } else { $this->__message = "Nhập sai cú pháp!"; } } $this->render('tac_vu_khach', array('form' => $form, 'message' => $this->__message)); }