Example #1
0
 public function resetPassword($username)
 {
     if (!\App::isGranted('resetPassword')) {
         redirect('admin/dashboard');
     }
     try {
         if (!$username) {
             throw new Exception("Error Processing Request.", 1);
         }
         $userManager = $this->container->get('user.user_manager');
         $user = $userManager->getUserByUsername($username);
         if (!$user) {
             throw new Exception("User not found.", 1);
         }
         //retrict if trying to edit super user
         if (\App::isSuperUser($user, false)) {
             redirect('admin/dashboard');
         }
         if (!$user->isActive()) {
             throw new Exception("User is currently disabled.", 1);
         }
         if ($this->input->post()) {
             $ruleManager = $this->container->get('user.rule_manager');
             $this->form_validation->set_rules($ruleManager->getRules(array('password', 'confPassword')));
             if ($this->form_validation->run($this)) {
                 $user->setPassword(password_hash($this->input->post('password'), PASSWORD_BCRYPT));
                 $userManager->updateUser($user);
                 $this->session->setFlashMessage('feedback', "User ({$user->getUsername()}) password has been reset.", 'success');
                 redirect(site_url('admin/user'));
             }
         }
         $this->breadcrumbs->push('Reset Password', current_url());
         $this->templateData['pageTitle'] = 'Reset Password';
         $this->templateData['user'] = $user;
         $this->templateData['content'] = 'user/reset_password';
         $this->load->view('backend/main_layout', $this->templateData);
     } catch (\Exception $e) {
         $this->session->setFlashMessage('feedback', "Unable to reset password: {$e->getMessage()}", 'error');
         redirect(site_url('admin/user'));
     }
 }
Example #2
0
if ($status == null) {
    ?>
					<th>Status</th>
				<?php 
}
?>
				<th width="15%">Action</th>
			</tr>
		</thead>
		<tbody>
			<?php 
$count = isset($offset) ? $offset : 0;
// $count=0;
$list = 0;
foreach ($users as $user) {
    if (\App::isSuperUser($user, false)) {
        continue;
    }
    if ($status == \user\models\User::STATUS_TRASH) {
        if ($user->getStatus() != $status) {
            continue;
        }
    }
    if ($status == \user\models\User::STATUS_ACTIVE) {
        if ($user->getStatus() == \user\models\User::STATUS_TRASH || $user->getStatus() == \user\models\User::STATUS_PENDING) {
            continue;
        }
    }
    $count++;
    $list++;
    ?>