Пример #1
0
function ensure_authenticated()
{
    if (!is_authenticated()) {
        $CI =& get_instance();
        $CI->session->set_flashdata('status', 'You are not allowed to view the page. Please login.');
        // returns immediatly
        redirect(login_route());
    }
}
Пример #2
0
<div id="navigation">
    <ul>
        <?php 
if (!is_authenticated()) {
    ?>
            <li><a href="<?php 
    echo home_route();
    ?>
">Home</a></li>
            <li><a href="<?php 
    echo signup_route();
    ?>
">Sign up</a></li>
            <li><a href="<?php 
    echo login_route();
    ?>
">Login</a></li>
        <?php 
} else {
    ?>
            <li><a href="<?php 
    echo profile_route();
    ?>
">Home</a></li>
            <li><a href="<?php 
    echo usersearch_route();
    ?>
">Search</a></li>
            <li><a href="<?php 
    echo settings_route();
Пример #3
0
 public function changepassword($email = '', $code = '')
 {
     // If get request with email/code parameters treat it like a post
     // This will be the case when people click the link in the email
     if ($email != '') {
         $_POST['email'] = urldecode($email);
     }
     if ($code != '') {
         $_POST['resetcode'] = $code;
     }
     // If there is any post data
     if ($_POST) {
         // Post data is found
         $this->load->model("user/ChangePasswordInput");
         // Check if input is valid
         if ($this->ChangePasswordInput->is_valid()) {
             // Try to validate
             $this->load->model('user/UserModel');
             $success = $this->UserModel->change_password($this->ChangePasswordInput);
             if ($success) {
                 // Set status message
                 set_status_message('Your password have been changed. Please login');
                 // Redirct
                 return redirect(login_route());
             }
             $this->form_validation->add_error('resetcode', 'The reset code is invalid.');
         }
     }
     // Default fallback
     $this->template->load('user/changepassword');
 }