persist() public static method

public static persist ( $duration = '2 weeks' )
コード例 #1
0
 function login()
 {
     if (empty($this->data)) {
         return;
     }
     $type = strstr($this->data['User']['login'], '@') ? 'credentials' : 'username';
     $maintainer = Authsome::login($type, $this->data['User']);
     if (!$maintainer) {
         $this->Session->setFlash(__('Unknown user or incorrect Password', true));
         return;
     }
     $remember = !empty($this->data['Maintainer']['remember']);
     if ($remember) {
         Authsome::persist('2 weeks');
     }
     if ($maintainer) {
         $this->Session->setFlash(__('You have been logged in', true));
         $this->redirect(array('controller' => 'users', 'action' => 'dashboard'));
     }
 }
コード例 #2
0
ファイル: users_controller.php プロジェクト: spx/spark_plug
 function login()
 {
     if (empty($this->data)) {
         return;
     }
     $user = Authsome::login($this->data['User']);
     if (!$user) {
         $this->Session->setFlash('Unknown user or wrong password');
         return;
     }
     $remember = !empty($this->data['User']['remember']);
     if ($remember) {
         Authsome::persist('2 weeks');
     }
     $this->Session->write("User", $user);
     $this->Session->write("User.id", $user["User"]["id"]);
     $this->Session->write("UserGroup.id", $user["UserGroup"]["id"]);
     $this->Session->write("UserGroup.name", $user["UserGroup"]["name"]);
     $this->Session->write('Company.id', $user['Company']['id']);
     $this->redirect('/dashboard');
 }
コード例 #3
0
 function login()
 {
     $this->loadModel('User');
     ## account activation
     if (isset($_GET["ident"])) {
         #on success
         if ($this->User->activateAccount($_GET)) {
             $this->Session->setFlash("Thank you. Your METAREP account has been activated. Please login.");
             $this->redirect("/dashboard", null, true);
         } else {
             $this->Session->setFlash("There was a problem with your account information. Please contact " . METAREP_SUPPORT_EMAIL);
             $this->redirect("/dashboard", null, true);
             $this->flash("Sorry. There were problems in your account activation.", Configure::read('httpRootUrl') . '/users/login');
         }
     } else {
         if (empty($this->data)) {
             return;
         }
         $user = Authsome::login($this->data['User']);
         //if authentification failed
         if (!$user) {
             $this->Session->setFlash('Unknown user or wrong password');
             $this->redirect('/dashboard', null, true);
         }
         $remember = !empty($this->data['User']['remember']);
         if ($remember) {
             Authsome::persist('2 weeks');
         }
         //track user stats
         $this->loadModel('UserStats');
         $this->data = array('UserStats' => array('category' => __FUNCTION__, 'user_id' => $user["User"]["id"]));
         $this->UserStats->save($this->data);
         $this->Session->write("User", $user);
         $this->Session->write("User.id", $user["User"]["id"]);
         $this->Session->write("UserGroup.id", $user["UserGroup"]["id"]);
         $this->Session->write("UserGroup.name", $user["UserGroup"]["name"]);
         if ($user['User']['username'] === 'jamboree') {
             $this->redirect('/projects/view/1', null, true);
         } else {
             $this->redirect('/dashboard', null, true);
         }
     }
 }
コード例 #4
0
ファイル: users_controller.php プロジェクト: jedt/spark_plug
 function login()
 {
     $this->layout = Configure::read('front_end_layout');
     if (isset($_GET["ident"])) {
         if ($this->User->activateAccount($_GET)) {
             $this->flash("Thank you. Your account is now active.", Configure::read('httpRootUrl') . '/users/login');
         } else {
             $this->flash("Sorry. There were problems in your account activation.", Configure::read('httpRootUrl') . '/users/login');
         }
     } else {
         //check for facebook connect plugin available
         if ($this->Session->read('SparkPlug.facebookEnabled')) {
             // check if there is a facebook account logged in and there is no user logged in
             if ($this->Connect->me && !$this->Authsome->get()) {
                 // check if there is an user linked to this facebook account
                 $conds = array('external_auth_id' => 'facebook_' . $this->Connect->me['id']);
                 $fbuser = $this->User->find($conds);
                 // if user exists, do login with it
                 if ($fbuser) {
                     //debug('user exists. login');
                     $this->Session->write('SparkPlug.Users.loggedInByFacebook', true);
                     $this->force_login_as_user($fbuser['User']['id']);
                 } else {
                     //debug('user does not exist. create');
                     // if the user does not exist, create the user using his email as login and do login
                     $newUser = array();
                     $newUser['User']['username'] = $this->Connect->me['id'];
                     $newUser['User']['password'] = md5(uniqid());
                     $newUser['User']['email'] = $this->Connect->me['email'];
                     $newUser['User']['user_group_id'] = Configure::read('SparkPlug.default_group_for_new_facebook_accounts');
                     $newUser['User']['external_auth_id'] = 'facebook_' . $this->Connect->me['id'];
                     if ($this->User->save($newUser['User'])) {
                         $this->Session->setFlash('New user created and linked with your facebook account');
                         $this->Session->write('SparkPlug.Users.loggedInByFacebook', true);
                         $this->force_login_as_user($this->User->getLastInsertId());
                     } else {
                         $this->Session->setFlash('There was an error creating the new user');
                     }
                 }
                 ///debug($this->Connect->me);
             }
         }
         if (empty($this->data)) {
             return;
         }
         /*			if (!empty(Authsome::get()){
         			 $this->Session->setFlash('Already logged in, logout first');
         			 return;
         			 }
         			 */
         $user = Authsome::login($this->data['User']);
         if (!$user) {
             $this->Session->setFlash('Unknown user or wrong password');
             return;
         }
         $remember = !empty($this->data['User']['remember']);
         if ($remember) {
             Authsome::persist('2 weeks');
         }
         $this->Session->write("User", $user);
         $this->Session->write("User.id", $user["User"]["id"]);
         $this->Session->write("UserGroup.id", $user["UserGroup"]["id"]);
         $this->Session->write("UserGroup.name", $user["UserGroup"]["name"]);
         $this->Session->write('Company.id', $user['Company']['id']);
         // let's redirect to the page that triggered the login attempt
         $originAfterLogin = $this->Session->read('SparkPlug.OriginAfterLogin');
         $this->tinymce_filemanager_init();
         if (Configure::read('SparkPlug.redirectOriginAfterLogin') && $originAfterLogin != null) {
             $this->redirect($originAfterLogin);
         } else {
             // redirect to default location
             $this->redirect(Configure::read('SparkPlug.loginRedirect'));
         }
     }
 }
コード例 #5
0
 function login()
 {
     if (isset($_GET["ident"])) {
         if ($this->User->activateAccount($_GET)) {
             $this->flash("Thank you. Your account is now active.", Configure::read('httpRootUrl') . '/users/login');
         } else {
             $this->flash("Sorry. There were problems in your account activation.", Configure::read('httpRootUrl') . '/users/login');
         }
     } else {
         if (empty($this->data)) {
             return;
         }
         $user = Authsome::login($this->data['User']);
         if (!$user) {
             $this->Session->setFlash('Unknown user or wrong password');
             return;
         }
         $remember = !empty($this->data['User']['remember']);
         if ($remember) {
             Authsome::persist('2 weeks');
         }
         $this->Session->write("User", $user);
         $this->Session->write("User.id", $user["User"]["id"]);
         $this->Session->write("UserGroup.id", $user["UserGroup"]["id"]);
         $this->Session->write("UserGroup.name", $user["UserGroup"]["name"]);
         $this->Session->write('Company.id', $user['Company']['id']);
         $this->redirect(Configure::read('SparkPlug.loginRedirect'));
     }
 }