/** * Displays the login page */ public function actionLogin() { if (Yii::app()->user->isGuest) { $model = new UserLogin(); if (Yii::app()->user->getState('attempts-login') > 3) { //make the captcha required if the unsuccessful attemps are more of thee $model->scenario = 'withCaptcha'; } // collect user input data if (isset($_POST['UserLogin'])) { $model->attributes = $_POST['UserLogin']; // validate user input and redirect to previous page if valid if ($model->validate()) { $this->lastViset(); $this->redirect(Yii::app()->controller->module->returnUrl); } else { //if login is not successful, increase the attemps Yii::app()->user->setState('attempts-login', Yii::app()->user->getState('attempts-login', 0) + 1); if (Yii::app()->user->getState('attempts-login') > 3) { $model->scenario = 'withCaptcha'; //useful only for view } } } // display the login form $this->render('/user/login', array('model' => $model)); } else { $this->redirect(Yii::app()->controller->module->returnUrl); } }
/** * Displays the login page */ public function actionLogin() { if (Yii::app()->user->isGuest) { $model = new UserLogin(); // collect user input data if (isset($_POST['UserLogin'])) { $model->attributes = $_POST['UserLogin']; // validate user input and redirect to previous page if valid if ($model->validate()) { $this->lastViset(); if (isset($_POST['UserLogin']['redirect'])) { Yii::app()->user->setFlash('success', "Okay, you're set. We are sending you off to your offer now."); $this->redirect(urldecode($_POST['UserLogin']['redirect'])); } else { if (Yii::app()->user->returnUrl == '/index.php') { $this->redirect('/'); } else { $this->redirect(Yii::app()->user->returnUrl); } } } } // display the login form $this->render('/user/login', array('model' => $model)); } else { $this->redirect(Yii::app()->controller->module->returnUrl); } }
/** * Displays the login page */ public function actionLogin() { if (Yii::app()->user->isGuest) { $model = new UserLogin(); // collect user input data if (isset($_POST['UserLogin'])) { $model->attributes = $_POST['UserLogin']; // validate user input and redirect to previous page if valid if ($model->validate()) { $this->lastViset(); $msg = 'Пользователь ' . $model->username . ' вошел в систему'; Yii::app()->logger->write($msg); // if (preg_match('/index.php$/', Yii::app()->user->returnUrl))//if ('/index.php') if (Yii::app()->user->returnUrl == '/index.php') { $this->redirect(Yii::app()->controller->module->returnUrl); } else { $this->redirect(Yii::app()->user->returnUrl); } } } // display the login form $this->render('/user/login', array('model' => $model)); } else { $this->redirect(Yii::app()->controller->module->returnUrl); } }
/** * Displays the login page */ public function actionLogin() { if (Yii::app()->user->isGuest) { $model = new UserLogin(); // collect user input data if (isset($_POST['UserLogin'])) { $model->attributes = $_POST['UserLogin']; // validate user input and redirect to previous page if valid if ($model->validate()) { $this->lastViset(); if (Yii::app()->user->returnUrl == '/index.php') { $this->redirect(Yii::app()->controller->module->returnUrl); } else { if (isAdmin()) { $this->redirect(PIUrl::createUrl('/admin')); } $this->redirect(Yii::app()->user->returnUrl); } } } // display the login form $this->render('/user/login', array('model' => $model)); } else { if (isAdmin()) { $this->redirect(PIUrl::createUrl('/admin')); } $this->redirect(Yii::app()->controller->module->returnUrl); } }
/** * Displays the login page */ public function actionLogin() { Yii::app()->theme = 'classic'; $this->layout = '//layouts/column2'; if (Yii::app()->user->isGuest) { $model = new UserLogin(); // collect user input data if (isset($_POST['UserLogin'])) { $model->attributes = $_POST['UserLogin']; // validate user input and redirect to previous page if valid // print_r($_POST); // print_r($_POST['UserLogin']); // exit; if ($model->validate()) { $this->lastViset(); if (strpos(Yii::app()->user->returnUrl, '/index.php') !== false) { $this->redirect(Yii::app()->controller->module->returnUrl); } else { $this->redirect(Yii::app()->user->returnUrl); } } } // display the login form $this->render('/user/login', array('model' => $model)); } else { $this->redirect(Yii::app()->controller->module->returnUrl);
/** * Displays the login page */ public function actionLogin() { if (Yii::app()->user->isGuest) { $model = new UserLogin(); // ajax validator if (isset($_POST['ajax']) && $_POST['ajax'] === 'login-form') { echo UActiveForm::validate(array($model)); Yii::app()->end(); } // collect user input data if (isset($_POST['UserLogin'])) { $model->attributes = $_POST['UserLogin']; // validate user input and redirect to previous page if valid if ($model->validate()) { $this->lastViset(); if (Yii::app()->user->returnUrl == '/index.php') { $this->redirect(Yii::app()->controller->module->returnUrl); } else { $this->redirect(Yii::app()->user->returnUrl); } } } // display the login form if (Yii::app()->request->isAjaxRequest) { $this->renderPartial('/user/login', array('model' => $model), '', true); } else { $this->render('/user/login', array('model' => $model)); } } else { $this->redirect(Yii::app()->controller->module->returnUrl); } }
/** * Displays the login page */ public function actionLogin() { if (Yii::app()->user->isGuest) { $model = new UserLogin(); // collect user input data if (isset($_POST['UserLogin'])) { $model->attributes = $_POST['UserLogin']; // validate user input and redirect to previous page if valid if ($model->validate()) { $u = User::model()->findByPk(Yii::app()->user->id); if ($u->myyja != 0) { Yii::app()->user->setState('myyja', true); $this->redirect(array('/site/myyja')); } $this->lastViset(); if (Yii::app()->user->returnUrl == '/index.php') { $this->redirect(array('/site/ruoka_paivakirja')); } else { $this->redirect(array('/site/ruoka_paivakirja')); } } } // display the login form $this->render('/user/login', array('model' => $model)); } else { $this->redirect(Yii::app()->controller->module->returnUrl); } }
/** * Displays the login page */ public function actionLogin() { if (Yii::app()->user->isGuest) { $model = new UserLogin(); // collect user input data if (isset($_POST['UserLogin'])) { $model->attributes = $_POST['UserLogin']; // validate user input and redirect to previous page if valid if ($model->validate()) { $this->lastViset(); $this->redirect(Yii::app()->user->returnUrl); // if (Yii::app()->user->returnUrl=='/index.php') // $this->redirect(Yii::app()->controller->module->returnUrl); // else // $this->redirect(Yii::app()->user->returnUrl); } } elseif (isset($_SERVER['HTTP_REFERER']) && !strpos($_SERVER['HTTP_REFERER'], 'login')) { //if referrer is available, set it as returnUrl Yii::app()->user->returnUrl = $_SERVER['HTTP_REFERER']; } // display the login form $this->render('/user/login', array('model' => $model)); } else { $this->redirect(Yii::app()->user->returnUrl); } }
/** * Displays the login page */ public function actionLogin() { if (Yii::app()->user->isGuest) { $model = new UserLogin(); // collect user input data if (isset($_POST['UserLogin'])) { $model->attributes = $_POST['UserLogin']; // validate user input and redirect to previous page if valid if ($model->validate()) { $this->lastViset(); //LOG THE uSER $userRequestOjb = new UserRequest(); $userRequestOjb->user_agent = @$_SERVER['HTTP_USER_AGENT']; $userRequestOjb->ip_address = @$_SERVER['REMOTE_ADDR']; $userRequestOjb->url_refferer = @Yii::app()->user->returnUrl; $userRequestOjb->save(); //END OF USER LOG if (Yii::app()->user->returnUrl == '/index.php') { $this->redirect(Yii::app()->controller->module->returnUrl); } else { $this->redirect(Yii::app()->user->returnUrl); } } } // display the login form $this->render('/user/login', array('model' => $model)); } else { $this->redirect(Yii::app()->controller->module->returnUrl); } }
/** * Formulaire de connexion */ public function actionLogin() { /** @var myWebUser $webUser */ if (Yii::app()->user->isGuest) { $model = new UserLogin(); if (isset($_POST['UserLogin'])) { // Connexion demandée $model->attributes = $_POST['UserLogin']; if ($model->validate()) { if (!$this->registerLastLogin()) { Yii::log(h::_('Erreur sur registerLastLogin()', __FILE__, __LINE__, __METHOD__), CLogger::LEVEL_ERROR); } Yii::app()->user->setFlash('success', Yii::t('UserModule.msg', 'You are now logged to your user account')); if (Yii::app()->user->returnUrl == '/index.php') { Yii::log(h::_(Yii::app()->user->getId(), __FILE__, __LINE__, __METHOD__), 'debug'); $this->redirect(Yii::app()->controller->module->returnUrl); } else { Yii::log(h::_(Yii::app()->user->getId(), __FILE__, __LINE__, __METHOD__), 'debug'); Yii::log(h::_(Yii::app()->user->returnUrl, __FILE__, __LINE__, __METHOD__), 'debug'); $this->redirect(Yii::app()->user->returnUrl); } } } // Affichage du formulaire de connexion (affichage initial ou erreur de validation) $this->render('/user/login', array('model' => $model)); } else { // Utilisateur déjà connecté, RAF $this->redirect(Yii::app()->controller->module->returnUrl); } }
/** * Displays the login page */ public function actionLogin() { if (Yii::app()->user->isGuest) { $model = new UserLogin(); // collect user input data if (isset($_POST['UserLogin'])) { $model->attributes = $_POST['UserLogin']; // validate user input and redirect to previous page if valid if ($model->validate()) { $this->lastViset(); $url = Yii::app()->controller->module->returnUrl; $this->redirect($url); //print_r($url); } } // display the login form if (isset($this->location)) { $this->render('frontend.views.user.login', array('model' => $model)); } else { $this->render('/user/login', array('model' => $model)); } } else { $this->redirect(Yii::app()->user->returnUrl); } }
/** * Displays the login page */ public function actionLogin() { $this->layout = 'application.modules.admin.views.layouts.loginlayout'; if (Yii::app()->user->isGuest) { $model = new UserLogin(); // collect user input data if (isset($_POST['UserLogin'])) { $model->attributes = $_POST['UserLogin']; // validate user input and redirect to previous page if valid if ($model->validate()) { $this->lastViset(); //exit(); if (strpos(Yii::app()->user->returnUrl, '/index.php') !== false) { $this->redirect(Yii::app()->controller->module->returnUrl); } else { $this->redirect(Yii::app()->user->returnUrl); } } } // display the login form $this->render('/user/login', array('model' => $model)); } else { $this->redirect(Yii::app()->controller->module->returnUrl); } }
public function actionLogin() { $this->layout = false; if (Yii::app()->user->isGuest) { $model = new UserLogin(); // collect user input data if (isset($_POST['UserLogin'])) { $model->attributes = $_POST['UserLogin']; // validate user input and redirect to previous page if valid if ($model->validate()) { $this->lastViset(); if (Yii::app()->getBaseUrl() . "/index.php" === Yii::app()->user->returnUrl) { $this->redirect(Yii::app()->controller->module->returnUrl); } else { $this->redirect(Yii::app()->user->returnUrl); } // $this->redirect(array('/core/default/index')); } else { print_r($model->errors); } } // display the login form $this->render('login', array('model' => $model)); } else { $this->redirect(Yii::app()->controller->module->returnUrl); } }
/** * Displays the login page */ public function actionLogin() { if (Yii::app()->user->isGuest) { $model = new UserLogin(); // collect user input data if (isset($_POST['UserLogin'])) { $model->attributes = $_POST['UserLogin']; // validate user input and redirect to previous page if valid if ($model->validate() && Yii::app()->user->id) { // Check if is set CodeCard code if CodeCard authentication is required $code_card = Yii::app()->getModule('user')->codeCard; if (!empty($code_card['require']) && !Yii::app()->user->hasState('valid_login_code_is_set')) { $this->redirect(array('/user/login/enterCode')); } $this->_finishLogin(); } } // display the login form //$this->render('/user/login',array('model'=>$model)); // special view for www login form if (isset($_GET['www'])) { $this->render('/user/www_login', array('model' => $model)); } else { $this->render('/user/ace_login', array('model' => $model)); } } elseif (isset($_GET['www'])) { Yii::app()->end(); } else { $this->redirect(Yii::app()->controller->module->returnUrl); } }
/** * Executes the widget. * This method is called by {@link CBaseController::endWidget}. */ public function run() { if (!$this->isCurrentUrlAllowed()) { return; } // $assetUrl = $this->publishAssets(); $module = Yii::app()->getModule('user'); # Call this before using any other classes from Yii-user $model = new UserLogin(); # to provide import of all needed classes in UserModule::init() $viewName = 'loginWidgetForm'; if (isset($_POST['UserLogin'])) { $model->attributes = $_POST['UserLogin']; // validate user input and redirect to previous page if valid if ($model->validate()) { } } if (Yii::app()->user->isGuest) { ?> <div class="form row"> <?php echo CHtml::beginForm(); ?> <?php echo CHtml::errorSummary($model); ?> <span class="column small-6"> <?php echo CHtml::activeTextField($model, 'username', array('size' => 15, 'placeholder' => 'Username')); ?> </span> <span class="column small-6"> <?php echo CHtml::activePasswordField($model, 'password', array('size' => 15, 'placeholder' => 'Password')); ?> </span> <span class="submit column small-4"> <?php echo CHtml::submitButton(UserModule::t("Login")); ?> </span> <?php echo CHtml::endForm(); ?> </div> <?php $form = new CForm(array('elements' => array('username' => array('type' => 'text', 'maxlength' => 32), 'password' => array('type' => 'password', 'maxlength' => 32), 'rememberMe' => array('type' => 'checkbox')), 'buttons' => array('login' => array('type' => 'submit', 'label' => 'Login'))), $model); ?> <?php } else { ?> <?php echo UserModule::t('Logged in as {username}', array('{username}' => CHtml::link($module->user()->username, $module->profileUrl))); ?> <?php } }
/** * Displays the login page */ public function actionLogin() { $this->layout = '//layouts/login'; if (Yii::app()->user->isGuest) { $model = new UserLogin(); if (isset($_POST['UserLogin'])) { $model->attributes = $_POST['UserLogin']; $model->username = trim($model->username); $model->password = trim($model->password); $model->verifyCode = trim($model->verifyCode); if ($model->validate()) { Yii::app()->session['login_error_times'] = 0; //记录登录时间 $this->getlogintime(); //用户登录验证 $this->getlogin(); $organID = Yii::app()->user->getOrganID(); if (Yii::app()->user->isMaker()) { $this->redirect(array('/maker')); } else { if (Yii::app()->user->isDealer()) { //判断经销商账号是否激活 $statu = $this->getActive($organID); if ($statu == 0) { $this->redirect(array('/user/agreement/agreement')); // $this->redirect(array('/user/activation/index')); } elseif ($statu == 2) { $this->redirect(array('/user/activecompany/index')); } else { $this->redirect(array('/pap/sellerorder/index')); } } else { if (Yii::app()->user->isServicer()) { //判断修理厂账号是否激活 $statu = $this->getActive($organID); if ($statu == 0) { $this->redirect(array('/user/agreement/agreement')); // $this->redirect(array('/user/activation/index')); } else { if ($statu == 2) { $this->redirect(array('/user/activecompany/index')); } else { $this->redirect(array('/pap/home/index')); } } } else { $this->redirect(Yii::app()->controller->module->returnUrl); } } } } } $this->render('/user/newlogin', array('model' => $model)); } else { //$this->getlogin(); $this->redirect(Yii::app()->controller->module->returnUrl); } }
/** * Displays the login page */ public function actionLogin() { if (Yii::app()->user->isGuest) { $model = new UserLogin(); // collect user input data if (isset($_POST['UserLogin'])) { $model->attributes = $_POST['UserLogin']; // validate user input and redirect to previous page if valid if ($model->validate()) { $this->lastViset(); if (Yii::app()->user->returnUrl) { $this->redirect(Yii::app()->controller->module->returnUrl); } else { $this->redirect(Yii::app()->user->returnUrl); } } } if (isset($_POST['LoginForm'])) { $model->attributes = $_POST['LoginForm']; // validate user input and redirect to previous page if valid if ($model->validate()) { $this->lastViset(); if (Yii::app()->user->returnUrl) { $this->redirect(Yii::app()->controller->module->returnUrl); } else { $this->redirect(Yii::app()->user->returnUrl); } } } // display the login form $this->render('/user/login', array('model' => $model)); } else { // { // if(Yii::app()->user->isAdmin()) // { // $this->redirect( array('/site/admin') ); // } // else $this->redirect(Yii::app()->controller->module->returnUrl); } //$this->redirect( array('/site/start') ); // } }
/** * Displays the login page */ public function actionLogin() { if (Yii::app()->user->isGuest) { $model = new UserLogin; if (isset($_POST['UserLogin'])) { $model->attributes = $_POST['UserLogin']; if ($model->validate()) { $this->redirect(array("/admin/dashboard")); } } $this->render('index', array('model' => $model)); } else { $user_id = Yii::app()->user->id; if ($user_id != '') { $this->redirect(array("/admin/dashboard")); } else $this->redirect(Yii::app()->controller->module->returnUrl); } }
/** * Displays the login page */ public function actionLogin() { $siteurl = ''; if (isset($_SERVER['HTTP_REFERER'])) { $siteurl = $_SERVER['HTTP_REFERER']; } if (Yii::app()->user->isGuest) { $model = new UserLogin(); $model->redirectUrl = $siteurl; // collect user input data if (isset($_POST['UserLogin'])) { $model->attributes = $_POST['UserLogin']; // validate user input and redirect to previous page if valid if ($model->validate()) { $this->lastViset(); $siteurl1 = ''; if (isset($_POST['UserLogin']['redirectUrl'])) { $siteurl = explode('site', $_POST['UserLogin']['redirectUrl']); if (isset($siteurl[1])) { $siteurl1 = $siteurl[1]; } } if (Yii::app()->user->returnUrl == '/') { if ($siteurl1 == '/chooseProduct') { $reviewPage = str_replace('chooseProduct', 'reviewSend', $_POST['UserLogin']['redirectUrl']); $this->redirect($reviewPage); } else { $this->redirect(Yii::app()->controller->module->returnUrl); } } else { if ($siteurl1 == '/chooseProduct') { $this->redirect(Yii::app()->createUrl('/site/productLogin')); } else { $this->redirect(Yii::app()->user->returnUrl); } } } } // display the login form $this->render('/user/login', array('model' => $model)); } else { $this->redirect(Yii::app()->controller->module->returnUrl); } }
/** * Displays the login page */ public function actionLogin() { if (Yii::app()->user->isGuest) { $model = new UserLogin(); // collect user input data if (isset($_POST['UserLogin'])) { $model->attributes = $_POST['UserLogin']; // validate user input and redirect to previous page if valid if ($model->validate()) { $this->lastViset(); //Yii::import('application.controllers.ActivityFeedController'); //SmsSettings::model()->sendSms($to,$from,$message); To call an action written on a controller //Adding activity to feed via saveFeed($initiator_id,$activity_type,$goal_id,$goal_name,$field_name,$initial_field_value,$new_field_value) ActivityFeed::model()->saveFeed(Yii::app()->user->Id, '1', NULL, NULL, NULL, NULL, NULL); $roles = Rights::getAssignedRoles(Yii::app()->user->Id); // check for single role foreach ($roles as $role) { if (sizeof($roles) == 1 and $role->name == 'Company') { $this->redirect(array('/students')); } } if (sizeof($roles) == 1 and $role->name == 'Trainee') { $this->redirect(array('/students')); } if (sizeof($roles) == 1 and $role->name == 'Employee') { $this->redirect(array('/students')); } if (Yii::app()->user->checkAccess('admin')) { if (Yii::app()->user->returnUrl == '/index.php') { $this->redirect(Yii::app()->controller->module->returnUrl); } else { $this->redirect(Yii::app()->user->returnUrl); } } else { $this->redirect(array('/students')); } } } // display the login form $this->render('/user/login', array('model' => $model)); } else { $this->redirect(Yii::app()->controller->module->returnUrl); } }
/** * Displays the login page */ public function actionLogin() { header('Content-type: application/json'); if (isset($_POST['UserLogin']) && isset($_GET['callback'])) { $model = new UserLogin(); $model->attributes = $_POST['UserLogin']; if ($model->validate()) { $this->lastViset(); $result = array('correct' => true, 'error' => false, 'msg' => 'success'); } else { $model = null; $result = array('correct' => false, 'error' => true, 'msg' => 'validation'); } $json = CJSON::encode(array('result' => $result, 'data' => $model)); } else { $json = CJSON::encode(array('result' => array('correct' => false, 'error' => true, 'msg' => 'request_invalid'), 'data' => null)); } Yii::app()->end($_GET['callback'] . "(" . $json . ")", true); }
/** * Displays the login page */ public function actionLogin() { if (Yii::app()->user->isGuest) { $model = new UserLogin(); // collect user input data if (isset($_POST['UserLogin'])) { $model->attributes = $_POST['UserLogin']; // validate user input and redirect to previous page if valid if ($model->validate()) { $this->lastViset(); $this->redirect("/index.php/site/index"); } } // display the login form $this->render('/user/login', array('model' => $model)); } else { $this->redirect("/index.php/site/index"); } }
/** * Displays the login page. */ public function actionLogin() { $this->breadcrumbs = ['login']; if (Yii::app()->user->isGuest) { $model = new UserLogin(); if (isset($_POST['UserLogin'])) { $model->attributes = $_POST['UserLogin']; if ($model->validate()) { $this->lastViset(); if (Yii::app()->user->returnUrl == '/index.php') { $this->redirect(Yii::app()->controller->module->returnUrl); } else { $this->redirect(Yii::app()->user->returnUrl); } } } $this->render('/user/login', array('model' => $model)); } else { $this->redirect(Yii::app()->controller->module->returnUrl); } }
/** * Displays the login page */ public function actionLogin() { if (Yii::app()->user->isGuest) { $model = new UserLogin(); // collect user input data if (isset($_POST['UserLogin'])) { $model->attributes = $_POST['UserLogin']; // validate user input and redirect to previous page if valid if ($model->validate()) { $this->lastViset(); $roles = Rights::getAssignedRoles(Yii::app()->user->Id); // check for single role foreach ($roles as $role) { if (sizeof($roles) == 1 and $role->name == 'parent') { $this->redirect(array('/portal')); } } if (sizeof($roles) == 1 and $role->name == 'student') { $this->redirect(array('/portal')); } if (sizeof($roles) == 1 and $role->name == 'teacher') { $this->redirect(array('/portal')); } if (Yii::app()->user->checkAccess('admin')) { if (Yii::app()->user->returnUrl == '/index.php') { $this->redirect(Yii::app()->controller->module->returnUrl); } else { $this->redirect(Yii::app()->user->returnUrl); } } else { $this->redirect(array('/mailbox')); } } } // display the login form $this->render('/user/login', array('model' => $model)); } else { $this->redirect(Yii::app()->controller->module->returnUrl); } }
public function actionLogin() { // $model=new User(); // $model->username=$_POST['username']; // $model->password=$_POST['password']; // $model->verifyCode=$_POST['User']['verifyCode']; //// echo $model->validate(); // echo CActiveForm::validate($model); //// $model->attributes=$_POST['use'] //// echo $model-> if (!empty($_POST)) { $model = new UserLogin(); $model->username = $_POST['username']; $model->password = $_POST['password']; if ($model->validate()) { $this->redirect(Yii::app()->user->returnUrl); } var_dump($_POST); } $this->render('login'); // $this->redirect(Yii::app()->user->returnUrl); }
/** * Displays the login page */ public function actionLogin() { if (Yii::app()->user->isGuest) { $model = new UserLogin(); // collect user input data if (isset($_POST['UserLogin'])) { $model->attributes = $_POST['UserLogin']; // validate user input and redirect to previous page if valid if ($model->validate()) { $returnUrl = UserModule::getReturnUrl(!$this->isUserWasLogined()); $this->lastViset(); if (Yii::app()->getBaseUrl() . "/index.php" === $returnUrl) { $this->redirect(Yii::app()->controller->module->returnUrl); } else { $this->redirect($returnUrl); } } } // display the login form $this->render('/user/login', array('model' => $model)); } else { $this->redirect(Yii::app()->controller->module->returnUrl); } }
/** * Displays the login page */ public function actionLogin($service = null) { if ($service && isset(Yii::app()->eauth)) { /** @var EAuth $eauth */ $eauth = Yii::app()->eauth; $serviceIdentity = $eauth->getIdentity($service); $serviceIdentity->redirectUrl = Yii::app()->user->returnUrl; $serviceIdentity->cancelUrl = $this->createAbsoluteUrl('/login'); try { if ($serviceIdentity->authenticate() && $serviceIdentity->getIsAuthenticated()) { if (Yii::app()->user->isGuest) { $userOauth = UserOauth::model()->find('service = :service AND foreign_id = :id', array('service' => $service, 'id' => $serviceIdentity->getId())); if ($userOauth) { /** @var User $user */ $user = $userOauth->user; $userIdentity = new EAuthUserIdentity($serviceIdentity, $user); Yii::app()->user->login($userIdentity); $serviceIdentity->redirect(); } else { $eauthSession = isset(Yii::app()->session['eauth']) ? Yii::app()->session['eauth'] : array(); $eauthSession[$service] = $serviceIdentity->getAttributes(); Yii::app()->session['eauth'] = $eauthSession; $this->redirect(Yii::app()->getModule('user')->registrationUrl); } } else { /** @var User $user */ $exists = false; $user = User::model()->findByPk(Yii::app()->user->id); foreach ($user->userOauths as $userOauth) { if ($userOauth->service == $service && $userOauth->foreign_id == $serviceIdentity->getId()) { $exists = true; } } if (!$exists) { $userOauth = new UserOauth(); $userOauth->service = $service; $userOauth->foreign_id = $serviceIdentity->getId(); $userOauth->user_id = $user->id; $userOauth->save(); $user->resetCache(); } } } // Something went wrong, redirect to login page $this->redirect(array('/login')); } catch (EAuthException $e) { // save authentication error to session Yii::app()->user->setFlash('error', 'EAuthException: ' . $e->getMessage()); // close popup window and redirect to cancelUrl $serviceIdentity->redirect($serviceIdentity->getCancelUrl()); } } if (Yii::app()->user->isGuest) { $model = new UserLogin(); // collect user input data if (isset($_POST['UserLogin'])) { $model->attributes = $_POST['UserLogin']; // validate user input and redirect to previous page if valid if ($model->validate()) { $user = $this->lastViset(); if (Yii::app()->request->isAjaxRequest) { echo json_encode($user->getUserData); exit; } if (Yii::app()->user->returnUrl == '/index.php') { $this->redirect(Yii::app()->controller->module->returnUrl); } else { $this->redirect(Yii::app()->user->returnUrl); } } } // display the login form $this->render('/user/login', array('model' => $model)); } else { $this->redirect(Yii::app()->controller->module->returnUrl); } }
public function crt_admin() { $validate = UserLogin::validate(Input::all()); $validatedetails = UserDetails::validate(Input::all()); if ($validate->passes() and $validatedetails->passes()) { $defaultimg = 'default.png'; $userleave = new LeaveCounter(); $userleave->employee_id = Input::get('employeeid'); $userleave->remaining_leave = 10; $userleave->remaining_leave_wopay = 10; $userleave->save(); $userlogin = new UserLogin(); $userlogin->employee_id = Input::get('employeeid'); $userlogin->username = Input::get('username'); $userlogin->password = Hash::make(Input::get('password')); $userlogin->role = 'Administrator'; $userlogin->save(); $userdetails = new UserDetails(); $userdetails->employee_id = Input::get('employeeid'); $userdetails->firstname = Input::get('firstname'); $userdetails->surname = Input::get('surname'); $userdetails->profile_mage = 'img/' . $defaultimg; $userdetails->e_status = 'Administrator'; $userdetails->department = Input::get('department'); $userdetails->email = Input::get('email'); $userdetails->save(); return Redirect::route('create_admin')->with('message', 'Registered Successfully!'); } else { $validation = array_merge_recursive($validate->messages()->toArray(), $validatedetails->messages()->toArray()); return Redirect::route('create_admin')->withErrors($validation)->withInput(); } }
public function actionGmailSignup() { require_once Yii::app()->basePath . '/modules/user/views/src/Google_Client.php'; //require_once 'src/Google_Client.php'; // include the required calss files for google login require_once Yii::app()->basePath . '/modules/user/views/src/contrib/Google_PlusService.php'; require_once Yii::app()->basePath . '/modules/user/views/src/contrib/Google_Oauth2Service.php'; $client = new Google_Client(); $client->setApplicationName("Asig 18 Sign in with GPlus"); // Set your applicatio name $client->setScopes('https://www.googleapis.com/auth/analytics'); //$client->setScopes// set scope during user login $client->setClientId('33563737111-gtuhtrm5f7cd4t66023fao39k5u55ol7.apps.googleusercontent.com'); // paste the client id which you get from google API Console $client->setClientSecret('O6IEQPCZw71vDSYVkZ-yKkRF'); // set the client secret $client->setRedirectUri('http://instanttop.com/index.php/user/user/GmailSignup/oauth2callback/'); // paste the redirect URI where you given in APi Console. You will get the Access Token here during login success $client->setDeveloperKey('AIzaSyBKvfFpG2RUNIFgKDM-fe_6dja9LpJoXRA'); // Developer key $plus = new Google_PlusService($client); $oauth2 = new Google_Oauth2Service($client); // Call the OAuth2 class for get email address $google_client_id = '402738627423-lsvdi7fvl9bf7j8ai96lc6sri1evsq9b.apps.googleusercontent.com'; $google_client_secret = 'TfvlOFg9eevgL_muiOaxiTeL'; $google_redirect_url = 'https://instanttop.com/index.php/user/user/GmailSignup/oauth2callback/'; //path to your script $google_developer_key = 'AIzaSyCXtRDlIE1GzcZ5UC9AdE17ib53Gnnx8Qk'; $gClient = new Google_Client(); $gClient->setApplicationName('Login to Sanwebe.com'); $gClient->setClientId($google_client_id); $gClient->setClientSecret($google_client_secret); $gClient->setRedirectUri($google_redirect_url); $gClient->setDeveloperKey($google_developer_key); $google_oauthV2 = new Google_Oauth2Service($gClient); //If user wish to log out, we just unset Session variable if (isset($_REQUEST['reset'])) { unset($_SESSION['token']); $gClient->revokeToken(); header('Location: ' . filter_var($google_redirect_url, FILTER_SANITIZE_URL)); //redirect user back to page } if (isset($_GET['code'])) { $gClient->authenticate($_GET['code']); $_SESSION['token'] = $gClient->getAccessToken(); header('Location: ' . filter_var($google_redirect_url, FILTER_SANITIZE_URL)); return; } if (isset($_SESSION['token'])) { $gClient->setAccessToken($_SESSION['token']); } if ($gClient->getAccessToken()) { //For logged in user, get details from google using access token $user = $google_oauthV2->userinfo->get(); $user_id = $user['id']; $user_name = filter_var($user['name'], FILTER_SANITIZE_SPECIAL_CHARS); $email = filter_var($user['email'], FILTER_SANITIZE_EMAIL); $profile_url = filter_var($user['link'], FILTER_VALIDATE_URL); $profile_image_url = filter_var($user['picture'], FILTER_VALIDATE_URL); $personMarkup = "{$email}<div><img src='{$profile_image_url}?sz=50'></div>"; $_SESSION['token'] = $gClient->getAccessToken(); $username = $user_name; $lastname = $user['family_name']; $userData = User::model()->find('username="******" or email="' . $email . '"'); echo "heredf"; if ($userData) { echo "here"; $model = new UserLoginFB(); if (User::model()->find('username="******"')) { $model->username = $userData->username; } else { $model->email = $userData->email; } $model->password = $userData->password; if ($model->validate()) { Yii::app()->user->returnUrl = Yii::app()->request->urlReferrer; $this->redirect(Yii::app()->user->returnUrl); } } else { echo "string"; $model = new User(); $model->email = $email; $model->username = $username; $password = rand(0, 999999999); $pass = md5($password); $model->password = $pass; $model->status = 1; $model->create_at = date('Y-m-d H:i:s'); /* if(!$model->save()) { var_dump($model->getErrors());die("error"); } */ if ($model->save()) { $modelprofile = new Profile(); $modelprofile->user_id = $model->id; $modelprofile->lastname = $lastname; $modelprofile->firstname = $username; $modelprofile->save(); $model1 = new UserLogin(); $model1->username = $username; $model1->password = $password; if ($model1->validate()) { $Url = Yii::app()->request->urlReferrer; $this->redirect(Yii::app()->user->returnUrl); } //$this->redirect(Yii::app()->user->returnUrl); } $this->render('login', array('model' => $model)); } } else { //For Guest user, get google login url $authUrl = $gClient->createAuthUrl(); } }
public function actionCreate() { // check permissions // if (!Yii::app()->user->checkAccess('manageUser')) { // Helper::authException(); // } // models $UserLogin = new UserLogin(); $UserProfile = new UserProfile(); // role array for select $userRoles = UserRole::model()->findAll(); $rolesArray = array(); foreach ($userRoles as $UserRole) { if ($UserRole->RoleType != 'godAdministrator') { $rolesArray[$UserRole->UserRoleID] = $UserRole->RoleDesc; } elseif (Helper::hasRole('godAdministrator')) { $rolesArray[$UserRole->UserRoleID] = $UserRole->RoleDesc; } } // add default (empty value) to front of array $rolesArray = array('' => '') + $rolesArray; // form processing if (isset($_POST['UserLogin'], $_POST['UserProfile'])) { // redirect to the dashboard if 'Cancel' button clicked if (isset($_POST['button-cancel'])) { $this->redirect($this->createUrl('user/dashboard')); } // set UserLogin attributes and scenario $UserLogin->attributes = $_POST['UserLogin']; $UserLogin->IsPasswordReset = 1; // force password reset on first login $UserLogin->IsActive = 1; $UserLogin->scenario = 'create'; // set UserProfile attributes $UserProfile->attributes = $_POST['UserProfile']; $UserProfile->CompanyID = Yii::app()->user->companyID; // validate form submission $valid = $UserLogin->validate(); $valid = $UserProfile->validate() && $valid; if ($valid) { // save UserLogin if (!$UserLogin->save(false)) { throw new CHttpException(400, 'Error when trying to create user.'); } // save UserProfile $UserProfile->UserLoginID = $UserLogin->UserLoginID; // set newly generated EventID if (!$UserProfile->save(false)) { throw new CHttpException(400, 'Error when trying to create user.'); } // set success message for user Yii::app()->user->setFlash('success', 'A new user was successfully created.'); // return to empty create user form if adding another, else go to user dashboard if (isset($_POST['button-submit-add'])) { $this->redirect($this->createUrl('user/create')); } else { $this->redirect($this->createUrl('user/dashboard')); } } } // clear password $UserLogin->UserPassword = null; // render view $this->render('create', array('UserLogin' => $UserLogin, 'UserProfile' => $UserProfile, 'rolesArray' => $rolesArray)); }