当前位置: 首页>>代码示例>>PHP>>正文


PHP User_Model::randomPassword方法代码示例

本文整理汇总了PHP中User_Model::randomPassword方法的典型用法代码示例。如果您正苦于以下问题:PHP User_Model::randomPassword方法的具体用法?PHP User_Model::randomPassword怎么用?PHP User_Model::randomPassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在User_Model的用法示例。


在下文中一共展示了User_Model::randomPassword方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: newUserRegistration

 public function newUserRegistration()
 {
     if ($this->config->item('allow_signup') == true) {
         // Check validation for user input in SignUp form
         $this->form_validation->set_rules('username', 'Username', 'trim|required');
         $this->form_validation->set_rules('email', 'Email', 'trim|required');
         $this->form_validation->set_rules('phone', 'Phone', 'trim|required');
         $this->form_validation->set_rules('firstName', 'First Name', 'trim|required');
         $this->form_validation->set_rules('lastName', 'Last Name', 'trim|required');
         $this->form_validation->set_rules('password', 'Password', 'trim|required');
         if ($this->form_validation->run() == false) {
             $this->load->view('login/registration_form');
         } else {
             if ($this->config->item('require_password_reset') == true) {
                 $password = User_Model::randomPassword();
             } elseif ($this->config->item('require_password_reset') == false) {
                 $password = password_hash($this->input->post('password'), PASSWORD_DEFAULT);
             }
             $data = array('username' => $this->input->post('username'), 'email' => $this->input->post('email'), 'phone' => $this->input->post('phone'), 'first_name' => $this->input->post('firstName'), 'last_name' => $this->input->post('lastName'), 'password' => $password);
             $result = $this->login->registrationInsert($data);
             if ($result == true) {
                 $data['message_display'] = 'Registration Successful!';
                 $this->load->view('login/login_form', $data);
             } else {
                 $data['message_display'] = 'Username already exist!';
                 $this->load->view('login/registration_form', $data);
             }
         }
     } else {
         $this->session->set_flashdata('error', 'The site admin does not allow user signup.');
         redirect('home');
     }
 }
开发者ID:brandon-bailey,项目名称:osdms,代码行数:33,代码来源:User_authentication.php

示例2: createNewUser

 public function createNewUser($formData)
 {
     if (!$this->userObj->isAdmin()) {
         echo json_encode(array('status' => 'error', 'msg' => 'You do not have permission to create a new user.'));
         exit;
     }
     // Check to make sure user does not already exist
     $userExists = User_model::exists($formData['username']);
     // If the above statement returns more than 0 rows, the user exists, so display error
     if ($userExists > 0) {
         echo json_encode(array('status' => 'error', 'msg' => 'A user with that name already exists.'));
         exit;
     } else {
         $phonenumber = @$formData['phone'];
         if (!isset($formData['canAdd'])) {
             $formData['canAdd'] = 0;
         }
         if (!isset($formData['canCheckin'])) {
             $formData['canCheckin'] = 0;
         }
         $userArray = array('username' => $formData['username'], 'password' => User_Model::randomPassword(), 'department' => $formData['department'], 'phone' => $phonenumber, 'email' => $formData['email'], 'last_name' => $formData['last_name'], 'first_name' => $formData['first_name'], 'can_add' => $formData['canAdd'], 'can_checkin' => $formData['canCheckin'], 'pw_reset_code' => 1);
         $userId = User_Model::createUser($userArray);
         if (!isset($formData['admin'])) {
             $formData['admin'] = '0';
         }
         $adminArray = array('id' => $userId, 'admin' => $formData['admin']);
         //Sets the correct admin settings for the new user
         User_Model::newUserAdmin($adminArray);
         if (isset($formData['departmentReview'])) {
             for ($i = 0; $i < sizeof($formData['departmentReview']); $i++) {
                 $deptId = $formData['departmentReview'][$i];
                 $deptArray = array('dept_id' => $deptId, 'user_id' => $userId);
                 //sets the reviewer status for the new user
                 User_model::newUserReviewer($deptArray);
             }
         }
         /*
         // mail user telling him/her that his/her account has been created.
         $newUserObj = new User($userId, $pdo);
         $date = date('M-d-Y H:i');
         $getFullName = $this->userObj->getFullName();
         $fullName = $getFullName[0].' '.$getFullName[1];
         $getNewFullName = $newUserObj->getFullName();
         $newUserFullName = $getNewFullName[0].' '.$getNewFullName[1];
         
         $body= (file_get_contents('templates/emails/user-email-template.html'));
         $body = str_replace('$fullName', $newUserFullName, $body);
         $body = str_replace('$userName', $newUserObj->getName(), $body);
         
         $body = str_replace('$base_url', $base_url, $body);
         $body = str_replace('$msg','Your Document Management account was created by '. $fullName . ' on ' . $date , $body);
         $body = str_replace('$date', $date, $body);
         $body = str_replace('$email', $this->userObj->getEmailAddress(), $body);
         $body = str_replace('$siteName', msg('email_automated_document_messenger'), $body);
         $body = str_replace('$phoneNumber', $this->userObj->getPhoneNumber(), $body);
         $body = str_replace('$creator', $fullName, $body);
         
         if($GLOBALS['CONFIG']['authen'] == 'mysql')
         {
         $body = str_replace('$password', $_POST['password'], $body);
         }
         
         $mail = new PHPMailer;
         $mail->isSendmail();
         $mail->setFrom($this->userObj->getEmailAddress(), $fullName);
         $mail->Subject = msg('message_account_created_add_user');
         $mail->msgHTML($body);
         $mail->addAddress($newUserObj->getEmailAddress() ,  $newUserFullName);
         if (!$mail->send()) {
         echo "Mailer Error: " . $mail->ErrorInfo;
         break;
         } else {
         echo "Message sent!";
         }
         */
     }
 }
开发者ID:brandon-bailey,项目名称:osdms,代码行数:77,代码来源:User_admin_model.php


注:本文中的User_Model::randomPassword方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。