CodeIgniter Forums
CI total newbie topic - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: CI total newbie topic (/thread-33458.html)

Pages: 1 2 3


CI total newbie topic - El Forum - 08-26-2010

[eluser]keevitaja[/eluser]
Hello,

i just started looking into to the framework. My first one. Which lightweight authentication system i should use? I only need usergroups (admin and user).

Thanks


CI total newbie topic - El Forum - 08-26-2010

[eluser]Lucas Alves[/eluser]
Hi,

In my opinion, Ion_Auth is a good choice. It's very lightweight and well coded, so you can adapt it to your needs if you want.


CI total newbie topic - El Forum - 08-26-2010

[eluser]Phil Sturgeon[/eluser]
+1 for Ion Auth


CI total newbie topic - El Forum - 08-26-2010

[eluser]keevitaja[/eluser]
can someone walk me through the installation of this Ion Auth. Readme doesn't really explain it to the first time CI user.


CI total newbie topic - El Forum - 08-26-2010

[eluser]Lucas Alves[/eluser]
Just run the sql script and copy the files into application respective folders...

MySql Script:
http://github.com/benedmunds/CodeIgniter-Ion-Auth/blob/master/ion_auth.sql

The doc:
http://benedmunds.com/ion_auth/


CI total newbie topic - El Forum - 08-26-2010

[eluser]tkyy[/eluser]
just use your own, i linked a very simple one on my blog here- http://www.taky.bz/a-basic-codeigniter-authentication-controller/

in the constructor of your controller files throw this under the parent::controller(); line:

Code:
$this->userdata = $this->session->userdata;

which will load up the userdata and return it from the sessions table as an array for you to play with. and then pass the userdata down to the view in the functions like

Code:
$data['userdata'] = $this->userdata;

so you don't do multiple queries, you just grab it each time the controller loads. moving forward you can throw this into the controller under the first line i just gave you to make sure a user is logged in:

Code:
if($this->userdata['logged']!=1){ $this->session->sess_destroy(); redirect(base()); }

so if the user tries to access an internal page it will destroy any session they may have had an redirect them to root. i truly believe this is the most versatile solution as opposed to using a precanned lib like XXXauth TEN or jAUTH or sAUTH or yaAUTHlib lol. i've even gone so far as to make access levels and a subsequent function i ended up throwing into the helper to do steps in a signup (a secure banking signup at that), so like in the constructor of your controller once again:

Code:
access(10);

would allow the user access to the tenth, ninth, eighth and below pages but not to pages higher than access level 10, as defined in their respective constructor functions. i made a new function in my helper called userdata() which either returns the userdata in array format if no input is given, or, just like codeigniter can either take 2 args (a key and a val) and add them to the userdata in the sessions table or an array of data as well.

i think i posted an early version of my standard helper here: http://www.taky.bz/codeigniter-helpers-file-the-standard-file-i-use/


CI total newbie topic - El Forum - 08-26-2010

[eluser]bretticus[/eluser]
[quote author="Phil Sturgeon" date="1282855331"]+1 for Ion Auth[/quote]

Geesh Phil! Is there currently any CodeIgniter project that you do not currently have a hand in? When do you find the time? I'm in here on the forums too often as it is. I don't have the time (or your mad skillz) to work everyone else's project and contribute to core. Smile Some of us must work for a living! Just checking...and thanks! :-)

@keevitaja It's not terribly hard to write your own if it's simple (I mean if you've ever written session based logins before for PHP and you don't need a plethora of flexibility.) Otherwise, in Open-source World it's perfectly acceptable to build your empire on the backs of others. Enjoy the free code!


CI total newbie topic - El Forum - 08-26-2010

[eluser]Rolly1971[/eluser]
i agree with Phil +1 for Ion Auth. Simple to implement, and very easy to use. even comes with all the form templates. great lightweight auth system.


CI total newbie topic - El Forum - 08-26-2010

[eluser]Lucas Alves[/eluser]
And what about D.R.Y.?


CI total newbie topic - El Forum - 08-27-2010

[eluser]keevitaja[/eluser]
how to access CI libraries from my custom library?
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class SimpleAuth {
  public function createUser($username, $password) {
    $CI =& get_instance();
    $CI->load->library('database');
    
  }
}
?>

this code gives me the error while loading the database