EllisLab text mark
Advanced Search
1 of 10
1
   
The Authentication Library 1.0.6
Posted: 23 June 2009 09:21 AM   [ Ignore ]
Avatar
Joined: 2008-05-04
356 posts

I have made some changes to The Authentication Library. Firstly i have fixed some general bugs that led to conflicts between group and group_id throughout the library. I have also implemented some changes that was submitted to me by a user via Github (please post if this was you!!) such as configurable table names and paths to views and models.

If you find any bugs I would appreciate it if you could post them over on the Issue Tracker.

As always all files can be downloaded from the Github repo.

Thanks guys.

 Signature 

[ Adam Griffiths - Freelance Web Applications Developer ]
[ Follow me on Twitter ]

 
Posted: 09 July 2009 03:09 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2009-01-06
39 posts

Can’t say how well I like this library as I haven’t been able to get it working. I followed the installation instructions and all is well until I actually try to access the register function (step 3). There is is no register function in the admin controller. Huh? Nor does login work by entering admin/login. All I get is a 404 page for both. I have renamed my various CI folders, but noted that in the config array so CI knows where to find everything. And my initial controller works to load up a simple construction page, so I know the CI install is good (not my first time using CI, by the way. About my fifth, actually).

I’m kind of stuck now. Is there perhaps something else I need to change to get this working? I know this isn’t much information to go on, so ask if you need more to make an educated guess.

Thank you.

 Signature 

patrick ogren : proprietor
Square Bones Digital Design

 
Posted: 09 July 2009 03:58 PM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2009-01-06
39 posts

All right. To check this library out thoroughly, I did a clean install of CI 1.7.1 without any extras, and without changing the name of any folders. I set up the config for my MAMP environment (base_url). I get the welcome message. That is good. Means CI is running right.

Now I go through the Library installation again. Copy all the files over. Add the routes defs to the routes.php file. Set up the database locally with standard table names. Just as it should be. And guess what? I still get 404 errors trying to access index.php/admin/register and index.php/admin/login. There’s nothering there. The admin controller does not have a method called register or login, so how is this supposed to work? There has to be methods in the controller or CI will throw a 404 each time, or am I not privy to some secret way of getting controllers to load methods that aren’t explicity defined in the controller?

That would be neat trick and one I would remember in the future.

So far, this library is a dud. I would really like to get it working as it seems very thorough, though I did find some inconsistencies. Such as… the name of the user and group tables are set in the Auth config file, but in MY_Controller and Usermodel both, the name of the users table is set explicitly in the db queries… can’t have it both ways, right? If a user changes the names of the tables in the config file, that blows the functionality of MY_Controller and Usermodel, right? Just checking…

I think maybe something got busted with the update. Perhaps Adam can take a look at his files and figure out what is going wrong and why this thing doesn’t appear to work from the outset.

Too bad.

 Signature 

patrick ogren : proprietor
Square Bones Digital Design

 
Posted: 12 July 2009 04:30 PM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Joined: 2009-07-08
3 posts

Same for me. 404 error when trying to register a user…

 
Posted: 12 July 2009 06:07 PM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Avatar
Joined: 2008-05-04
356 posts
squarebones - 09 July 2009 07:58 PM

All right. To check this library out thoroughly, I did a clean install of CI 1.7.1 without any extras, and without changing the name of any folders. I set up the config for my MAMP environment (base_url). I get the welcome message. That is good. Means CI is running right.

Now I go through the Library installation again. Copy all the files over. Add the routes defs to the routes.php file. Set up the database locally with standard table names. Just as it should be. And guess what? I still get 404 errors trying to access index.php/admin/register and index.php/admin/login. There’s nothering there. The admin controller does not have a method called register or login, so how is this supposed to work? There has to be methods in the controller or CI will throw a 404 each time, or am I not privy to some secret way of getting controllers to load methods that aren’t explicity defined in the controller?

That would be neat trick and one I would remember in the future.

So far, this library is a dud. I would really like to get it working as it seems very thorough, though I did find some inconsistencies. Such as… the name of the user and group tables are set in the Auth config file, but in MY_Controller and Usermodel both, the name of the users table is set explicitly in the db queries… can’t have it both ways, right? If a user changes the names of the tables in the config file, that blows the functionality of MY_Controller and Usermodel, right? Just checking…

I think maybe something got busted with the update. Perhaps Adam can take a look at his files and figure out what is going wrong and why this thing doesn’t appear to work from the outset.

Too bad.

To get a few things out of the way first…the MY_Controller.php file has the Application class which has the login and register functions. By extending the Application class all of the Application classes functions are accessible from the admin controller. This is a simple element of Object Oriented programming, so no secret tricks!

As for the database names, the only place I have seen where I have missed using the variable for the database name is the Model. This is a fair point and I’m fixing this issue right no by adding two functions to the helper. The updated helper and model are in the Github repo.

One thing I noticed was that you were navigating to index.php/admin/register when you should just go to index.php/register. Maybe this is the case and hopefully that works for you.

If not I’d appreciate an email off you explaining your setup so I can fix anything on my end if needs be. *email removed*


Thanks.

 Signature 

[ Adam Griffiths - Freelance Web Applications Developer ]
[ Follow me on Twitter ]

 
Posted: 12 July 2009 10:08 PM   [ Ignore ]   [ # 5 ]   [ Rating: 0 ]
Avatar
Joined: 2009-01-06
39 posts

Thank you for responding, Adam. I’ll try both those things and download your update. I am very interested in getting a good authentication library working for my sites. I have something that Bramme created, and it works, but I was never sure how secure it was. And it isn’t as complete as I would like it as it really just checks authorization, rather than providing further authentication functions, as yours does.

Anyway, your’s is just one in a string of libraries I have tried, and with no luck with any of them. Like I said, the only library that worked ‘as advertised’ was Bramme’s.

I’ll keep you apprised of any progress I make here in the forum, rather than through your e-mail, so that it might help other users of your library.

P.S. Thanks for the glimpse into the workings of MY_Controller. Not having been weaned on OOP, I am used to pure procedural programming, and getting my head around some concepts in OOP is difficult as I feel like it is some sort of black magic. Now I see that using this extension is quite powerful and adds to the flexibility of the framework even more.

 Signature 

patrick ogren : proprietor
Square Bones Digital Design

 
Posted: 13 July 2009 12:22 PM   [ Ignore ]   [ # 6 ]   [ Rating: 0 ]
Joined: 2009-07-08
3 posts

It seems that 404 error was due to incorrect index.php/admin/register instead of just index.php/register, but then you need to update the documentation wink

However, with the recent two changes from Github I get this error:
Fatal error: Call to undefined function user_table() in C:\wamp\www\freshci\system\application\models\Usermodel.php on line 14

Except of that it seems to work just fine (I hardcoded the user table back again wink)

One idea I have is to add to the user edit form also possibility to modify user’s group_id, since now by default it is 100 and you have to digg in DB to change it.

 
Posted: 21 July 2009 08:50 PM   [ Ignore ]   [ # 7 ]   [ Rating: 0 ]
Joined: 2008-06-27
120 posts

I want to include the login view on my home page and the “$this->load->view(‘login’);”.

This is good, and the login form shows, but it can’t login.  I guess it’s restricted to the login view specifically?  I’d like this to ajax submit too.

I’m new to CI and PHP…can this be done with your library?

I also want to restrict functions from users who are not logged in.

ie.

if(user_logged_in()){
do this;
}
else{
do that;

Could you help me out?

Thanks!

 
Posted: 27 July 2009 12:20 PM   [ Ignore ]   [ # 8 ]   [ Rating: 0 ]
Avatar
Joined: 2008-08-29
307 posts

I added this bit of code to auth_helper.php to get a users ID - I prefer storing ID’s and running queries that check against ID’s rather than username strings… Hopefully you’ll add this to the next release? smile

function user_id()
{
    $CI 
=& get_instance();
    return 
$CI->session->userdata('user_id');
 Signature 

CodeIgniter From Scratch: Day 1 | Day 2 | Day 3 | Day 4 | Day 5 | Day 6 | Day 7

 
Posted: 27 July 2009 12:34 PM   [ Ignore ]   [ # 9 ]   [ Rating: 0 ]
Joined: 2008-01-18
128 posts

Hi Adam,
Interesting solution and trying it out.

In my case on a Fedora Core 9 server, I had to change the config file Auth.php (application/config/Auth.php) to auth.php (application/config/auth.php).

Hope this helps someone else.

 
Posted: 28 July 2009 03:14 PM   [ Ignore ]   [ # 10 ]   [ Rating: 0 ]
Joined: 2009-07-28
2 posts

Hi

So far using the Authentication Library has been a breeze - very simple setup and simple to use, overall very happy!

This is the first problem I’ve encountered - I’m looking to implement this system in a subdomain [http://subdomain.domain.com/]

CI seems to be working fine - I get the welcome page, however with any controller extending application I get the error:

The configuration file auth.php does not exist.

I have placed a .htaccess file which contains:

RewriteEngine on
RewriteCond 
$!^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond 
%{REQUEST_FILENAME} !-d
RewriteRule 
^(.*)$ ./index.php/$1 [L,QSA] 

To be quite honest, I have no idea about .htaccess files.

Another aspect that is different from the base CI install is within config.php - which contains this code instead of the usual:

$config['base_url'=  ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'== "on") ?  "https" "http");
$config['base_url'.=  "://".$_SERVER['HTTP_HOST'];
$config['base_url'.=  str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']); 

I’m not entirely sure where the problem might be, but I can take a guess that it’s located within the MY_Controller.php script.

Any help would be greatly appreciated - I’m still rather new at CI, and it would be super-awesome, if I could implement this system within a subdomain.

Best,

Andy

 
Posted: 28 July 2009 03:27 PM   [ Ignore ]   [ # 11 ]   [ Rating: 0 ]
Avatar
Joined: 2008-05-04
356 posts
Pxlfusion - 28 July 2009 07:14 PM

Hi

So far using the Authentication Library has been a breeze - very simple setup and simple to use, overall very happy!

This is the first problem I’ve encountered - I’m looking to implement this system in a subdomain [http://subdomain.domain.com/]

CI seems to be working fine - I get the welcome page, however with any controller extending application I get the error:

The configuration file auth.php does not exist.

I have placed a .htaccess file which contains:

RewriteEngine on
RewriteCond 
$!^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond 
%{REQUEST_FILENAME} !-d
RewriteRule 
^(.*)$ ./index.php/$1 [L,QSA] 

To be quite honest, I have no idea about .htaccess files.

Another aspect that is different from the base CI install is within config.php - which contains this code instead of the usual:

$config['base_url'=  ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'== "on") ?  "https" "http");
$config['base_url'.=  "://".$_SERVER['HTTP_HOST'];
$config['base_url'.=  str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']); 

I’m not entirely sure where the problem might be, but I can take a guess that it’s located within the MY_Controller.php script.

Any help would be greatly appreciated - I’m still rather new at CI, and it would be super-awesome, if I could implement this system within a subdomain.

Best,

Andy

Hi,


Simply rename Auth.php (config file) to auth.php (all lowercase) as this is aproblem with the linux kernel.


Thanks,
Adam

 Signature 

[ Adam Griffiths - Freelance Web Applications Developer ]
[ Follow me on Twitter ]

 
Posted: 28 July 2009 03:47 PM   [ Ignore ]   [ # 12 ]   [ Rating: 0 ]
Joined: 2009-07-28
2 posts

Ah! Simple solution - Thanks very much Adam.

 
Posted: 29 July 2009 04:09 PM   [ Ignore ]   [ # 13 ]   [ Rating: 0 ]
Joined: 2008-01-18
128 posts

Hi Andy,

I’m by no means any expert on CI or the Authentication Library but I’ll try to give you another perspective.

I’m not sure your problem lies within the MY_Controller.php script. I had an error and on Linux, I had to rename the file from Auth.php to auth.php and it worked.

I’d think your controllers are fine and htaccess since as you said, you can see your Welcome Controller.

As for those confi[‘base_url’] entries, I’m quite perplexed, never seen them that complicated in CI before.

HTH

 
Posted: 03 August 2009 04:32 AM   [ Ignore ]   [ # 14 ]   [ Rating: 0 ]
Joined: 2009-08-02
1 posts

Hi,

Just a minor error in Auth.php I found as I changed the table names:-

if($login === TRUE)
            
{
                $data2[
'msg'"The user has been created, you have now been logged in.";
                
                
$userdata $this->CI->db->query("SELECT * FROM `users` WHERE `username` = '$username'"); 

should be:-

if($login === TRUE)
            
{
                $data2[
'msg'"The user has been created, you have now been logged in.";
                
                
$userdata $this->CI->db->query("SELECT * FROM `$this->user_table` WHERE `username` = '$username'"); 

RottenSod.

 
Posted: 03 August 2009 07:59 AM   [ Ignore ]   [ # 15 ]   [ Rating: 0 ]
Joined: 2008-01-04
300 posts

DELETE

 
1 of 10
1