function recover_password($data) { $result = FALSE; $msg = ''; $user = $this->_query_reader->get_row_as_array('search_user_list', array('phrase' => $data['registeredemail'], 'limit_text' => 'LIMIT 1')); if (!empty($user['user_id'])) { # generate_temp_password is a helper function in common_functions_helper file $password = generate_temp_password(); $result = $this->_messenger->send($user['user_id'], array('code' => 'password_recovery_notification', 'emailaddress' => $data['registeredemail'], 'password' => $password, 'directionlink' => base_url() . 'accounts/login'), array('email'), TRUE); if (!$result) { $msg = "ERROR: The message with your temporary password could not be sent."; } #if user's password was sent if ($result) { $result = $this->_query_reader->run('update_user_password', array('user_id' => $user['user_id'], 'password' => sha1($password))); if (!$result) { $msg = "ERROR: The password update failed."; } } } else { $msg = "WARNING: There is no valid user with the given email address."; } return array('boolean' => $result, 'msg' => $msg); }
<tr><td class='label'>User Name</td><td><input type='text' id='newusername' name='newusername' <?php echo !empty($user['user_name']) ? " class='bold' " : ''; ?> placeholder='Choose a User Name (Min 6 Characters)' value='<?php echo !empty($user['user_name']) ? $user['user_name'] : ''; ?> ' <?php if (!empty($user['user_name'])) { echo ' readonly'; } ?> /></td></tr> <tr><td class='label'>Password</td><td><input type='password' id='newpassword' name='newpassword' placeholder='Choose a Password (Min 8 Characters with a number)' value='<?php echo !empty($user['password']) ? $user['password'] : generate_temp_password(); ?> '/></td></tr> <tr><td class='label'>Permission Group</td><td><select id='user__<?php echo $groupList; ?> ' name='user__<?php echo $groupList; ?> ' class='drop-down' style="width:calc(100% + 17px);"> <?php echo get_option_list($this, $groupList, 'select', '', array('selected' => !empty($user['permission_group_id']) ? $user['permission_group_id'] : '')); ?> </select></td></tr>