/**
  *	@fn login
  *	@short Action method to perform a login.
  */
 function login()
 {
     if ($this->request->is_post()) {
         $conn = Db::get_connection();
         $user_factory = new User();
         $users = $user_factory->find_all(array('where_clause' => "`username` = '{$conn->escape($_POST['username'])}' AND `password` = '" . md5($_POST['password']) . "'", 'limit' => 1));
         if (count($users) > 0) {
             $user = $users[0];
             $expires = $_POST['leave_me_registered'] ? Time::next_year() : Time::tomorrow();
             Cookie::set('_u', $user->username, $expires, "/", FALSE);
             Cookie::set('_uid', md5(Login::magic_phrase . $user->password), $expires, "/", FALSE);
             // Annotates the login in the database
             $user_login = new UserLogin();
             $user_login->user_id = $user->id;
             $user_login->performed_at = date("Y-m-d H:i:s");
             $user_login->save();
             $this->flash(sprintf(l('Welcome, %s'), $user->first), 'info');
             // When login is required to access a particular action, we may store controller & action in a session,
             // perform login, then redirect to the action requested in the first place
             if (isset($_SESSION['redirect_to'])) {
                 $this->redirect_to(array('controller' => $_SESSION['redirect_to']['controller'], 'action' => $_SESSION['redirect_to']['action']));
             } else {
                 $this->redirect_to(array('controller' => 'home'));
             }
             Db::close_connection($conn);
         } else {
             $this->flash(l('Bad username / password'), 'error');
         }
     }
     $this->redirect_to(array('action' => 'index'));
 }
 /**
  * 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);
     }
 }
Exemple #3
0
    /**
     * 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 
        }
    }
Exemple #4
0
 public function actionAddcompany()
 {
     $companyModel = new Company();
     $userLoginModel = new UserLogin();
     $userProfileModel = new UserProfile();
     if (isset($_POST['Company'])) {
         $companyModel->attributes = $_POST['Company'];
         $userLoginModel->attributes = $_POST['UserLogin'];
         $userProfileModel->attributes = $_POST['UserProfile'];
         if ($companyModel->validate()) {
             if ($companyModel->save()) {
                 $userLoginModel->UserRoleID = 2;
                 // $userLoginModel->LoginEmail = '*****@*****.**';
                 $userLoginModel->UserPassword = md5($userLoginModel->UserPassword);
                 $userLoginModel->IsPasswordReset = 1;
                 $userLoginModel->IsActive = 1;
                 $userLoginModel->save();
                 $userProfileModel->UserLoginID = $userLoginModel->UserLoginID;
                 $userProfileModel->CompanyID = $companyModel->CompanyID;
                 // $userProfileModel->FirstName = 'Test';
                 // $userProfileModel->LastName = 'test';
                 $userProfileModel->AgreeToTerms = 0;
                 $userProfileModel->IsFacilitator = 0;
                 $userProfileModel->save();
                 $this->redirect(Yii::app()->createUrl('admin/setup', array('id' => $companyModel->CompanyID)));
             }
         }
     }
     $this->render('add-company', array('companyModel' => $companyModel, 'userLoginModel' => $userLoginModel, 'userProfileModel' => $userProfileModel));
 }
Exemple #5
0
 /**
  * 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);
     }
 }
 /**
  * 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);
     }
 }
Exemple #7
0
 /**
  * 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);
     }
 }
 /**
  * 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();
         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();
                 //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);
     }
 }
Exemple #11
0
 /**
  * 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);
     }
 }
Exemple #12
0
 /**
  * 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);
     }
 }
 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);
     }
 }
Exemple #14
0
 /**
  * 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()
 {
     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);
Exemple #16
0
 /**
  * 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);
     }
 }
Exemple #18
0
 /**
  * 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);
     }
 }
Exemple #19
0
 public function test_validation()
 {
     MemoryStore::flush();
     UserLogin::delete_all();
     User::delete_all();
     $user = new User();
     FuzzyTest::assert_false($user->validate(), "User write should fail because required properties were not set");
     FuzzyTest::assert_true(key_exists("email", $user->validation_errors), "Email validation error not set");
     FuzzyTest::assert_true(key_exists("password", $user->validation_errors), "Password validation error not set");
     FuzzyTest::assert_true(key_exists("accepted_terms_and_conditions", $user->validation_errors), "Boolean validation error not set");
     FuzzyTest::assert_true(key_exists("registration_date", $user->validation_errors), "Required validation error not set");
     $user->accepted_terms_and_conditions = true;
     $user->validate();
     FuzzyTest::assert_false(key_exists("accepted_terms_and_conditions", $user->validation_errors), "Boolean validation error erroneously set");
     $user->email = "*****@*****.**";
     $user->validate();
     FuzzyTest::assert_false(key_exists("email", $user->validation_errors), "Email validation error erroneously set");
     $user->password = "******";
     $user->validate();
     FuzzyTest::assert_false(key_exists("password", $user->validation_errors), "Password validation error erroneously set");
     $user->registration_date = new Date();
     $user->validate();
     FuzzyTest::assert_false(key_exists("registration_date", $user->validation_errors), "Required validation error erroneously set");
     $user->first_name = "Ben";
     $user->last_name = "Copsey";
     $user->validate();
     FuzzyTest::assert_false(key_exists("first_name", $user->validation_errors), "Length validation error erroneously set");
     FuzzyTest::assert_false(key_exists("last_name", $user->validation_errors), "Length validation error erroneously set");
     FuzzyTest::assert_true($user->validate(), "Validate should succeed because required properties were set");
 }
Exemple #20
0
 public function test_simple_write()
 {
     MemoryStore::flush();
     UserLogin::delete_all();
     User::delete_all();
     $user = new User();
     $user->email = "*****@*****.**";
     $user->password = "******";
     $user->accepted_terms_and_conditions = true;
     $user->registration_date = new Date("2008-12-12");
     $user->first_name = "Ben";
     $user->last_name = "Copsey";
     FuzzyTest::assert_true($user->write_new(), "Write should succeed because required properties were set");
     $user = new User();
     $user->email = "*****@*****.**";
     $user->password = "******";
     $user->accepted_terms_and_conditions = true;
     $user->registration_date = new Date();
     $user->first_name = "Ben";
     $user->last_name = "Copsey";
     FuzzyTest::assert_false($user->write_new(), "Write should fail because we have a duplicate for a unique property");
     $user = new User();
     $user->email = "*****@*****.**";
     $user->password = "******";
     $user->accepted_terms_and_conditions = true;
     $user->registration_date = new Date();
     $user->first_name = "Ben";
     $user->last_name = "Copsey";
     FuzzyTest::assert_true($user->save(), "Save should succeed as a write_new");
 }
 public function getofline($id)
 {
     # code...
     $user_login = UserLogin::findOne(['id' => $id]);
     $user_login->ONLINE = 0;
     $user_login->save();
 }
 /**
  * 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()
 {
     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);
     }
 }
Exemple #24
0
 /**
  * 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);
     }
 }
Exemple #25
0
 /**
  * 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') );
     // }
 }
Exemple #26
0
 /**
  * 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()
 {
     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);
 }
Exemple #28
0
 /**
  * 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);
     }
 }
 public function testAction($some)
 {
     return $this->render('UserActionBundle:User:recentList.html.twig', array('articles' => $articles));
     //*
     $user = $this->getDoctrine()->getRepository('UserActionBundle:User')->find($some);
     //var_dump($user);exit;
     $categoryName = $user->getUserLogin()->getLogin();
     var_dump($categoryName);
     exit;
     //*/
     $userLogin = new UserLogin();
     $userLogin->setLogin($some);
     $userLogin->setPassword('gello');
     $userLogin->setHash('hello');
     $userLogin->setConfirmationCode('hello');
     $user = new User();
     $user->setName($some);
     // Связывает этот продукт с категорией
     $user->setUserLogin($userLogin);
     // add suer
     $userLogin->setUser($user);
     $em = $this->getDoctrine()->getEntityManager();
     $em->persist($userLogin);
     $em->persist($user);
     $em->flush();
     return new Response('Created $user id: ' . $user->getId() . ' and $userLogin id: ' . $userLogin->getId());
     //return $this->render('UserActionBundle:Default:index.html.twig', array('name' => $some));
 }
 /**
  * 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);
     }
 }