Added a logout button

Logout button will now appear in the header if authentication is enabled
and the user is logged in.
This commit is contained in:
Daniel 2012-09-30 14:10:41 -04:00
parent dc8b8eaa46
commit aab3832e02
4 changed files with 10 additions and 18 deletions

View File

@ -78,7 +78,7 @@ class Auth extends CI_Controller {
} else { } else {
$data['logged_in'] = FALSE; $data['logged_in'] = FALSE;
} }
$this->load->view('auth/logout_view', $data); redirect('/');
} }
} }

View File

@ -124,8 +124,8 @@ class Auth_Ldap {
*/ */
function logout() { function logout() {
// Just set logged_in to FALSE and then destroy everything for good measure // Just set logged_in to FALSE and then destroy everything for good measure
$this->ci->session->set_userdata(array('logged_in' => FALSE)); $this->ci->db_session->set_userdata(array('logged_in' => FALSE));
$this->ci->session->sess_destroy(); $this->ci->db_session->sess_destroy();
} }
/** /**

View File

@ -1,15 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Logout</title>
</head>
<body>
<?php if($logged_in): ?>
<p><?= $username ?> has been logged out.</p>
<p>Thanks for visiting <?= $name ?></p>
<?php else: ?>
<p>You need to <?php echo anchor('/auth/login', 'login', ''); ?> before you log out...</p>
<?php endif;?>
</body>
</html>

View File

@ -53,6 +53,13 @@ $this->carabiner->display('css');
<?php } ?> <?php } ?>
<li><a <?php if($l == "api"){ echo 'class="active"'; }?> href="<?php echo site_url('api'); ?>" title="API">API</a></li> <li><a <?php if($l == "api"){ echo 'class="active"'; }?> href="<?php echo site_url('api'); ?>" title="API">API</a></li>
<li><a <?php if($l == "about"){ echo 'class="active"'; }?> href="<?php echo site_url('about'); ?>" title="About">About</a></li> <li><a <?php if($l == "about"){ echo 'class="active"'; }?> href="<?php echo site_url('about'); ?>" title="About">About</a></li>
<?php
if ($this->config->item('require_auth') ){
if ($this->auth_ldap->is_authenticated()){
echo "<li><a href=" . site_url('auth/logout') . ' title="Logout">Logout</a></li>';
}
}
?>
</ul> </ul>
</div> </div>