當前位置: 首頁>>代碼示例>>PHP>>正文


PHP User_Model::password_validate方法代碼示例

本文整理匯總了PHP中User_Model::password_validate方法的典型用法代碼示例。如果您正苦於以下問題:PHP User_Model::password_validate方法的具體用法?PHP User_Model::password_validate怎麽用?PHP User_Model::password_validate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在User_Model的用法示例。


在下文中一共展示了User_Model::password_validate方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: save

 public function save()
 {
     $user = new User_Model($_POST['id']);
     if (!$user->loaded) {
         $this->template->title = 'New Password Invocation Error';
         $this->template->content = new View('login/login_message');
         $this->template->content->message = 'Invalid user id.';
         return;
     }
     $username = $user->username;
     $password = $_POST['password'];
     $password2 = $_POST['password2'];
     $email_key = $_POST['email_key'];
     $person = ORM::factory('person', $user->person_id);
     if ($email_key != '') {
         /* if the email_key field is filled in, then being called from a forgotten password email */
         if ($user->forgotten_password_key != $email_key) {
             $this->template->title = 'New Password Invocation Error';
             $this->template->content = new View('login/login_message');
             $this->template->content->message = 'The forgotten password identification string embedded in this link is invalid for this user. This may be because there has been a valid login for this user between the point where the Set Password page was brought up and when the Submit button was pressed.';
             return;
         }
     } else {
         if (!empty($_SESSION['auth_user']) and is_object($_SESSION['auth_user']) and $_SESSION['auth_user'] instanceof User_Model and $_SESSION['auth_user']->loaded) {
             if ($user->id != $_SESSION['auth_user']->id) {
                 $this->template->title = 'New Password Invocation Error';
                 $this->template->content = new View('login/login_message');
                 $this->template->content->message = 'Inconsistent user id: POST vs logged in user.';
                 return;
             }
         } else {
             $this->template->title = 'New Password Invocation Error';
             $this->template->content = new View('login/login_message');
             $this->template->content->message = 'Attempt to set password when not logged in.';
             return;
         }
     }
     $user_validation = new Validation($_POST);
     $person_validation = new Validation($_POST);
     // override the user_id for person in submission
     $person_validation['id'] = $user->person_id;
     // Can't just and following together as I want both functions to run
     $userstatus = $user->password_validate($user_validation, false);
     $personstatus = $person->email_validate($person_validation, false);
     if ($userstatus and $personstatus) {
         $user->save();
         $person->save();
         // we need different paths for core users and web site users
         if (is_null($user->core_role_id)) {
             // just return a success confirmation, can't log them in as not a core user
             $this->template->title = 'Password reset successfully';
             $this->template->content = new View('login/login_message');
             $this->template->content->message = 'Your indicia password has been reset and you can now use the new password to <a href="' . url::site() . '/login">log in</a>.<br />';
         } else {
             // with the password updated, login and jump to the home page
             $this->auth->login($user->id, $password);
             url::redirect(arr::remove('requested_page', $_SESSION));
         }
     } else {
         // errors are now embedded in the model
         $view = new View('login/new_password');
         $user->load_values(array('username' => $username));
         // repopulate for error condition after validate has removed it (is a disabled field so not present in POST)
         // have to reset passord as it gets encrypted
         $view->password = $password;
         $view->password2 = $password2;
         $view->email_key = $email_key;
         $view->user_model = $user;
         $view->person_model = $person;
         $this->template->title = 'Enter New Password';
         $this->template->content = $view;
     }
 }
開發者ID:BirenRathod,項目名稱:indicia-code,代碼行數:73,代碼來源:new_password.php


注:本文中的User_Model::password_validate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。