EllisLab text mark
Advanced Search
1 of 10
1
   
The Authentication Library 1.0.6
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

 
Posted: 03 August 2009 08:46 AM   [ Ignore ]   [ # 16 ]   [ Rating: 0 ]
Avatar
Joined: 2008-05-04
356 posts
RottenSod - 03 August 2009 08:32 AM

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.

Thanks, I’ve fixed this and it’s now in the Github repo.

Daniel H - 03 August 2009 11:59 AM

Am I being incredibly special, or can I not download from github? In Safari the ZIP/TAR dialog just stays open and does nothing, while in Firefox the dialog closes but nothing is actually downloaded. I don’t think I’ve had problems downloading from github before…

A few people have been having problems with downloading the ZIPs from Github and unfortunately I can’t help with this as it is a problem with Github. The only thing I can suggest is to go to Github support and ask them what the problem might be.

 


Thanks,
Adam

 Signature 

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

 
Posted: 03 August 2009 01:13 PM   [ Ignore ]   [ # 17 ]   [ Rating: 0 ]
Avatar
Joined: 2009-06-19
6267 posts

Hi Adam,

I can not download from GitHub either, I emailed them and the problem is that it does not like IE Browsers they told me to switch to another browser!

Enjoy
InsiteFX

 Signature 

Ceritfied State of CT Computer Programming Teacher.
Custom Designed Icons, eBook Covers Software Boxes. CD, DVD Etc. New iPhone® Tab Bar Icons and iPhone® Applications Icons.

STOP! Before posting your questions, remember the WWW Golden rule:
What did you try? What did you get? What did you expect to get?

Input -> Controller | Processing -> Model | Output -> View

 
Posted: 04 August 2009 12:55 PM   [ Ignore ]   [ # 18 ]   [ Rating: 0 ]
Avatar
Joined: 2008-08-07
33 posts

Thanks for your hard work in creating this auth system.

I had two small problems getting everything set up.

1. When a user tries to logout there is a call to sess_destroy() but I had to change this to destroy(). The problem is not a fault with The Authentication Library but that I made some changes to the way sessions are handled in order to get SWFUpload working with the codeigniter upload class as per this thread
http://ellislab.com/forums/viewthread/97399/

2. When registering a user I got the following errors:

A PHP Error was encountered

Severity
Warning

Message
fopen() [function.fopen]php_network_getaddressesgetaddrinfo failedName or service not known

Filename
libraries/Auth.php

Line Number
348
A PHP Error was encountered

Severity
Warning

Message
fopen(http://random.org/strings/?num=1&len=20&digits=on&upperalpha=on&loweralpha=on&unique=on&format=plain&rnd=new) [function.fopen]: failed to open stream: No such file or directory

Filenamelibraries/Auth.php

Line Number
348
A PHP Error was encountered

Severity
Warning

Message
fread(): supplied argument is not a valid stream resource

Filename
libraries/Auth.php

Line Number
349 

This could be caused by some kind of infrastructure or server problem. I am testing this app from work and they have very strict I.T. policies, firewalls etc. It could also be some kind of server setting.

Here is the code from libraries/Auth.php around line 348:

if (ini_get('allow_url_fopen')) {
          
// Grab the random string using the easy version if we can
          
$token_source fopen($rand_url"r");
          
$token fread($token_source20);
        

My hunch is that the server restrictions and php.ini settings are not aligned. As the code checks the ini to see if it can use fopen(), as it is told there are no problems it gives it a try.

Either way the registration seems to work as expected so I have just suppressed the warnings like so…

if (ini_get('allow_url_fopen')) {
          
// Grab the random string using the easy version if we can
          
$token_source = @ fopen($rand_url"r");
          
$token = @ fread($token_source20);
        

Which works OK as $token contains a value like UnUmfDzdu7CQshCYqcD. I wonder however if it would be easier to generate the unique string a more like this:

$token sha1(mt_rand(10000,99999).time().$username); 

And then the whole if / ifelse / else section in the _genrate() function can be replaced?

Thanks again for your hard work on this great library.

 
Posted: 11 August 2009 12:21 AM   [ Ignore ]   [ # 19 ]   [ Rating: 0 ]
Joined: 2009-07-18
31 posts

I’ve uploaded your auth library and followed your installation instructions, as per your user guide, but it doesn’t seem to be working.  The users table is not recording a username or email address when I register.  All other fields are filled in.

I get a success message after registering and go to the dashboard but it says ‘Welcome .’, which after looking at the code for the dashboard page, should be echoing out the username.

It does seem to be holding the session details as I am not able to get back to the dashboard after logging out, without logging back in again, which is a fruitless effort as the database does not have any usernames.  If I add a username to a record in the database, I get an error when trying to login saying that the username and password combination did not match.

I must be missing a step somewhere but I’m not sure where as I have a clean install of CI and followed the installation instructions in the user guide.

 
Posted: 11 August 2009 09:41 AM   [ Ignore ]   [ # 20 ]   [ Rating: 0 ]
Avatar
Joined: 2008-05-04
356 posts

I do not know why the username or email address is not being added to the database. I will take a look into it but I need to know what version of PP you are running as everything works fine for me in PHP5.

Thanks,
Adam

 Signature 

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

 
Posted: 11 August 2009 12:54 PM   [ Ignore ]   [ # 21 ]   [ Rating: 0 ]
Joined: 2009-07-18
31 posts

I’m using PHP4 on a shared host.  Let me know if there’s anything else you need.

 
Posted: 06 September 2009 05:55 PM   [ Ignore ]   [ # 22 ]   [ Rating: 0 ]
Joined: 2009-04-13
143 posts

What have I done? In the case when my controller extends Application, my variables are not passing from controller (controllers/admin/admin.php) to view (views/auth/header.php)

Please point me to the docs or a relevant post. Otherwise… what might be my problem? Here’s my Admin controller

class Admin extends Application
{
    
function Admin()
    
{
        parent
::Application();
    
}
    
    
function index()
    
{
        
if(logged_in())
        
{
            $headerdata[
'title']='Administrative Control Panel'// note that $title never makes it to the view (undefined variable error)
            
$this->auth->view('admin/dashboard'$headerdata);
        
}
        
else
        
{
            $this
->auth->login(); // how to pass variables through to this thing?
        
}
    } 

I can pass variables just fine from controllers that do not extend Application. But here there are two different use cases.  When the user is already logged in then it does not pass variables.  When the user is not logged in, also I do not know how to pass variables to the view.

something about routes?

Again, I am very familiar with doing this in controllers that do not extend Application. Where should I look next?

thanks

—Sean Loving

 
Posted: 07 September 2009 12:50 AM   [ Ignore ]   [ # 23 ]   [ Rating: 0 ]
Avatar
Joined: 2009-06-19
6267 posts

Hi,

It should be:

$this->auth->view('dashboard'$headerdata); 

Also make sure you configured the root.php file for Auth.

Enjoy
InsiteFX

 Signature 

Ceritfied State of CT Computer Programming Teacher.
Custom Designed Icons, eBook Covers Software Boxes. CD, DVD Etc. New iPhone® Tab Bar Icons and iPhone® Applications Icons.

STOP! Before posting your questions, remember the WWW Golden rule:
What did you try? What did you get? What did you expect to get?

Input -> Controller | Processing -> Model | Output -> View

 
Posted: 07 September 2009 09:38 PM   [ Ignore ]   [ # 24 ]   [ Rating: 0 ]
Joined: 2009-04-13
143 posts

Thanks InsiteFX,

I have solved part of my problem and I thought it might be useful to others who might want to pass variable data to their header view files.

My problem was that I was trying to use the variable data in my auth/header.php view file.

In my regular controllers I usually call three views - header, main, and footer like this…

$this->load->view('header'$headerdata);
$this->load->view($page$maindata);
$this->load->view('footer'$footerdata); 

This way I can send different variable data to each of my three views that generate my page.

However, in my admin controllers things are handled a bit differently. The Auth Library automatically generates three view requests based on making one single call to the libraries/auth/view function like this:

$this->auth->view($page$data); 

which actually generates three separate view requests like this:

$this->auth->view('auth/header');
$this->auth->view('auth/pages/'.$page$data);
$this->auth->view('auth/footer'); 

Notice the generated header and the footer do NOT receive $data.  That was the problem.

Basically, the $this->auth->view function in libraries/Auth.php sends the request to the index.php file in views/auth

So I modified views/auth/index.php so that I can get $data to my auth/header and my auth/footer views like I like.  Here is the new views/auth/index.php file:

<?php
if(isset($data))
{
    $this
->load->view($this->config->item('auth_views_root') . 'header'$data);
    
$this->load->view($this->config->item('auth_views_root') . 'pages/'.$page$data);
    
$this->load->view($this->config->item('auth_views_root') . 'footer'$data);
}
else
{
    $this
->load->view($this->config->item('auth_views_root') . 'header');
    
$this->load->view($this->config->item('auth_views_root') . 'pages/'.$page);
    
$this->load->view($this->config->item('auth_views_root') . 'footer');
}
?> 

—seanloving

 
Posted: 07 September 2009 10:51 PM   [ Ignore ]   [ # 25 ]   [ Rating: 0 ]
Avatar
Joined: 2009-06-19
6267 posts

Hi seanloving,

Yes I am very well informed on the way Auth works, I am using it in Adams Fresh CMS which I am writing a menuing system for, the menuing system is working I am just cleaning it up etc.

 Signature 

Ceritfied State of CT Computer Programming Teacher.
Custom Designed Icons, eBook Covers Software Boxes. CD, DVD Etc. New iPhone® Tab Bar Icons and iPhone® Applications Icons.

STOP! Before posting your questions, remember the WWW Golden rule:
What did you try? What did you get? What did you expect to get?

Input -> Controller | Processing -> Model | Output -> View

 
1 of 10
1