Welcome Guest, Not a member yet? Register   Sign In
The Auth Library 1.0.3 - The Easiest Auth Library for CodeIgniter
#61

[eluser]jabberjab[/eluser]
How would you integrate this with captcha?
#62

[eluser]Adam Griffiths[/eluser]
I haven't used a captcha before, so I wouldn't really know. But it would depend on if you had your own captcha lib or used another one such as recaptcha and how it needs to be implemented and whether or not you could do that within The Authentication Library.
#63

[eluser]jabberjab[/eluser]
Alright, thank you. Will you implement a 'forgotten password' action for this library? Smile

Edit: I see the username is derivable via $this->session->userdata('username') but is this a safe approach? I guess the cookie is verified beforehand anyway, but I'd like some confirmation Smile Don't want other users to suddenly be able to edit other users' profile pages hehe.
#64

[eluser]J. Brenne[/eluser]
With including your library I lost the functions
Code:
Memory usage: {memory_usage}.
Page rendered in {elapsed_time} seconds

I use a diffrent MY_Controller
Code:
<?php
/**
* MY_Controller
*
* @author BBWG
* @version 2009
* @access public
*/
class MY_Controller extends Controller
{
    var $page_title;
    var $version = '0.01';
    var $datenstand;
    
    function MY_Controller()
    {
        parent::Controller();
        
        // load assets
        $this->assets();
        
        // load settings
        $this->load_settings();
        
        // activeate profiler?
        $this->output->enable_profiler(FALSE);
    }
    
    function load_settings()
    {
.....        
        $this->load->library('auth');
    }
    
    function assets()
    {
        $carabiner_config = array(
            'script_dir' => 'assets/scripts/',
            'style_dir'  => 'assets/styles/',
            'cache_dir'  => 'cache/assets/',
            'base_uri'     => $this->config->item('base_url'),
            'combine'     => TRUE,
            'dev'          => TRUE
        );
        $this->carabiner->config($carabiner_config);
        
        // include css
        $this->carabiner->css('styles.css');

    }
    
    function header()
    {
        $this->load->view('header',array('page_title' => $this->page_title,'version'=>$this->version,'datenstaende'=>$this->datenstand));
    }
    function footer()
    {
        $this->load->view('footer');
    }

    // simple page
    public function view($view, $data = array()) {
        $this->header();
        $this->load->view($view, $data);
        $this->footer();
    }

    function login()
    {
        $this->auth->login();
    }
    
    function logout()
    {
        $this->auth->logout();
    }
    
    function register()
    {
        $this->auth->register();
    }

    function username_check($str)
    {
        
        $auth_type = $this->auth->_auth_type($str);
        
        $query = $this->db->query("SELECT * FROM `users` WHERE `$auth_type` = '$str'");
        
        if($query->num_rows === 1)
        {
            return TRUE;
        }
        else
        {
            $this->form_validation->set_message('username_check', $this->lang->line('username_callback_error'));
            return FALSE;
        }

    } // function username_check()
    
    function reg_username_check($str)
    {
        $query = $this->db->query("SELECT * FROM `users` WHERE `username` = '$str'");
        
        if($query->num_rows <> 0)
        {
            $this->form_validation->set_message('reg_username_check', $this->lang->line('reg_username_callback_error'));
            return FALSE;
        }
        else
        {
            return TRUE;
        }

    } // function reg_username_check()
    
    function reg_email_check($str)
    {    
        $query = $this->db->query("SELECT * FROM `users` WHERE `email` = '$str'");
        
        if($query->num_rows <> 1)
        {
            return TRUE;
        }
        else
        {
            $this->form_validation->set_message('reg_email_check', $this->lang->line('reg_email_callback_error'));
            return FALSE;
        }

    } // function reg_email_check()

}
#65

[eluser]the1rob[/eluser]
Is there any known breakage with Auth library? In particular, benchmark?

I installed CI stock, then the Auth Lib 1.0.2. Just for the sake of testing Auth out, I extended the welcome controller.

err...changed it like so:

Code:
class Welcome extends Application
{

    function Welcome()
    {
        parent::Application();    
    }
    
    function index()
    {
    
        
        $this->load->view('welcome_message');
    }
    
}

Then added this to the welcome_message.php view...


Code:
<p> <a href="http://www.examplesite.com/index.php/admin/login">Login</a></p>
<p> <a href="http://www.examplesite.com/index.php/admin/register">Register</a></p>
<p> You are currently
&lt;?
    if ($this->auth->logged_in())
        {
            echo "ARE ";
        }
        else
        {
            echo "ARE NOT ";
        }
?&gt;

logged in.</p>

&lt;?php echo $this->benchmark->elapsed_time();?&gt;

The Auth code works fine. But the last line doesn't work anymore. Just shows "{elapsed_time}" in the final html output.

Am I missing something? I've only been playing with CI for a few days now, so please be gentle if I missed something obvious. =)
#66

[eluser]Adam Griffiths[/eluser]
I have no idea why those functions are lost when using The Authentication Library - I will look deeper into it. The post above yours might help you though.

Thanks.
#67

[eluser]playaz[/eluser]
[quote author="Christophe-France" date="1237546515"]the problem is in the application/libraries/Auth file :
[/quote]

I have applied this earlier 'permissions' fix and it all works fine now!

Just a question though, I cannot see what the user_area(), users_area() just_user() do as they seem to not work for me. For instance, if I go to the just_user controller via the URL it still allows me to view the page although logged in as admin or editor.

Am I doing something fundamentally wrong here? Anyone else had this problem
Code:
function user_area()
    {
        // This is accessible to all users
        $this->auth->restrict('user');
        echo("user area");
    }
    
    function users_area()
    {
        // This is accessible to all users too
        $this->auth->restrict();
        echo("user area");
    }
    
    function just_user()
    {
        // This is accessible to only 'users'
        $this->auth->restrict('user', TRUE);
        echo("user area only");
    }
#68

[eluser]Adam Griffiths[/eluser]
[quote author="playaz" date="1239396975"][quote author="Christophe-France" date="1237546515"]the problem is in the application/libraries/Auth file :
[/quote]

I have applied this earlier 'permissions' fix and it all works fine now!

Just a question though, I cannot see what the user_area(), users_area() just_user() do as they seem to not work for me. For instance, if I go to the just_user controller via the URL it still allows me to view the page although logged in as admin or editor.

Am I doing something fundamentally wrong here? Anyone else had this problem
Code:
function user_area()
    {
        // This is accessible to all users
        $this->auth->restrict('user');
        echo("user area");
    }
    
    function users_area()
    {
        // This is accessible to all users too
        $this->auth->restrict();
        echo("user area");
    }
    
    function just_user()
    {
        // This is accessible to only 'users'
        $this->auth->restrict('user', TRUE);
        echo("user area only");
    }
[/quote]

I think this is a bug that I didn't catch when pushing this update.

The next version of The Authentication Library will include ACL, so you will be able to restrict access to functions to specific groups.

I will also package an admin backend to help add/edit/delete users+ permissions etc.

Thanks.
#69

[eluser]playaz[/eluser]
Wow thanks Adam, that was a super fast reply!! Do you hardcore developers never sleep Smile

Anyway thanks again, I will be using this Library from now on can't wait for the next version of ACL, any idea when that will be? (not rushing you of course just really curious!)

Seriously though, I really appreciate this it is certainly helping a CI newbie pick up this awesome framework fast!

Thanks again, and take a break dude I think you deserve one :-)
#70

[eluser]Adam Griffiths[/eluser]
[quote author="playaz" date="1239397753"]Wow thanks Adam, that was a super fast reply!! Do you hardcore developers never sleep Smile

Anyway thanks again, I will be using this Library from now on can't wait for the next version of ACL, any idea when that will be? (not rushing you of course just really curious!)

Seriously though, I really appreciate this it is certainly helping a CI newbie pick up this awesome framework fast!

Thanks again, and take a break dude I think you deserve one :-)[/quote]

Haha! No I just happened to be online when you posted.

I really can't put a date to when the new version will come. I'll start to use github so you'll be able to access the newest version. The part which will take the longest time is probably the admin backend, I feel it is now a necessity due to the additions I am making.

I'm not sure how to do it though. Should I create a simple admin template, or just have the views and create functions to include the views (+ processing) in yourown admin backend?

Thanks.




Theme © iAndrew 2016 - Forum software by © MyBB