EllisLab text mark
Advanced Search
5 of 10
5
   
The Authentication Library 1.0.6
Posted: 16 October 2009 07:19 AM   [ # 61 ]   [ Rating: 0 ]
Joined: 2009-10-16
3 posts

Hi all. I compelled it to work, but I got anothe problem, it doesn`t want to work with Template CI Library (http://williamsconcepts.com/ci/codeigniter/libraries/template/reference.html)

I replace any where line like
$this->auth->view(‘dashboard’)

with

$this->template->write_view(‘content’,    $this->auth->view(‘dashboard’));
$this->template->render();

But it not work. Can anybody helps me?

 
Posted: 16 October 2009 07:33 AM   [ # 62 ]   [ Rating: 0 ]
Avatar
Joined: 2008-05-04
356 posts
wildarp - 16 October 2009 11:19 AM

Hi all. I compelled it to work, but I got anothe problem, it doesn`t want to work with Template CI Library (http://williamsconcepts.com/ci/codeigniter/libraries/template/reference.html)

I replace any where line like
$this->auth->view(‘dashboard’)

with

$this->template->write_view(‘content’,    $this->auth->view(‘dashboard’));
$this->template->render();

But it not work. Can anybody helps me?

In that case you’ll need to manually include the path to the view folder and the headers and footers. I’ve never used the Template Library you linked to, so this code is all just a guess form what you’ve put in your post.

$this->template->write_view('header',     $this->load->view('auth/header'));
$this->template->write_view('content',     $this->load->view('auth/dashboard'));
$this->template->write_view('footer',     $this->load->view('auth/footer'));
$this->template->render(); 

Hopefully this helps you out.

 

Thanks,
Adam

 Signature 

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

 
Posted: 24 October 2009 04:28 AM   [ # 63 ]   [ Rating: 0 ]
Joined: 2009-10-15
3 posts

Hi,

Just wanted to say I finally got it working.

I had database trouble. What I discovered was that importing the provided dump.sql file via phpMyAdmin, the ci_ prefix was trashed on the users and groups tables.

After adding the prefix to the tables I was able to successfully open the registration page, change my new user to admin, reauthenticate, and see the manage users options.

Im impressed overall. Definitely will be playing with this library over the next few weeks. See what I can do with it. smile

 
Posted: 01 November 2009 06:02 PM   [ # 64 ]   [ Rating: 0 ]
Joined: 2009-11-01
1 posts
function _verify_cookie()
{
    
if((array_key_exists('login_attempts'$_COOKIE)) && ($_COOKIE['login_attempts'>= 5))
    
{
        $username 
$this->CI->session->userdata('username');
        
$userdata $this->CI->db->query("SELECT * FROM `$this->user_table` WHERE `z_username` = '$username'");
        
        
$result $userdata->row();

        
$identifier $result->z_username $result->token;
        
$identifier $this->_salt($identifier);
        
        if(
$identifier !== $_COOKIE['logged_in'])
        
{
            $this
->CI->session->sess_destroy();
            
            
show_error($this->CI->lang->line('logout_perms_error'));
        
}
    }
    
else
    
{
        $this
->_generate();
    
}

Is this correct?

Right now, if you are logged in it generates a new identifier every page load. Should it not be, that if there is no cookie, it should generate an identifier?

 
Posted: 02 November 2009 11:39 PM   [ # 65 ]   [ Rating: 0 ]
Joined: 2009-10-20
46 posts

Hello, I’m having troubles with this:

A Database Error Occurred
Error Number: 1364

Field ‘token’ doesn’t have a default value

INSERT INTO `users` (username, email, password) VALUES (‘admin’, ‘alfjoin@gmail.com’, ‘xxxxxxxxxxxxxxxxxxxxxxxxxx’)

Its shown when I try to register a new user :/ Any Idea?

 
Posted: 04 November 2009 04:58 PM   [ # 66 ]   [ Rating: 0 ]
Joined: 2009-10-20
46 posts

Okay solved the isue myself,
the problem was that the ‘token’ field dosent have a default value on the mysql syntax, and no default values are passed trough the registration form, so the fix is just put as NULL both token and identifier fields.

The correct syntax should be:
CREATE TABLE IF NOT EXISTS `users` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  `password` varchar(255) NOT NULL,
  `group_id` int(11) NOT NULL DEFAULT ‘100’,
  `token` varchar(255) DEFAULT NULL,
  `identifier` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

 
Posted: 06 November 2009 10:52 AM   [ # 67 ]   [ Rating: 0 ]
Joined: 2009-02-21
8 posts

Hello,

I’m confused on how to use the Update feature for user accounts. I have tried visiting /admin/register as a logged in user, and have also tried visiting /admin/users/edit and /admin/users/edit/1 (for the user id), as I saw edit in the Users controller. Register just tries to edit again, and /users/edit tells me I don’t have sufficient privileges. For what it’s worth, /admin/users/manage returns the same privileges error.

Any advice on how to use this functionality?

Otherwise, I’m so far very impressed by the library. Good stuff.

Thanks,
Jonathan

 
Posted: 06 November 2009 02:24 PM   [ # 68 ]   [ Rating: 0 ]
Joined: 2009-10-20
46 posts

Hello Jonathan, Have you check that the user level is correct? also for register it should be /admin/admin/register, so you can register users.

 
Posted: 06 November 2009 02:31 PM   [ # 69 ]   [ Rating: 0 ]
Joined: 2009-02-21
8 posts

Thanks for the response. I did ensure that the user I’m testing with is in the admin group. Also, /admin/register lets me register users very nicely. It just doesn’t let me update them.. tries to re-register, of course.

Thanks,
Jonathan

 
Posted: 06 November 2009 02:36 PM   [ # 70 ]   [ Rating: 0 ]
Joined: 2009-10-20
46 posts

Could you post your register view code?

 
Posted: 06 November 2009 02:37 PM   [ # 71 ]   [ Rating: 0 ]
Joined: 2009-02-21
8 posts

Well, nevermind. I must have forgotten to clear the sessions table to reflect the group. I truncated the MySQL table, and all is well. Thanks muchly for pointing me in that direction.

Jonathan

 
Posted: 12 November 2009 05:32 PM   [ # 72 ]   [ Rating: 0 ]
Joined: 2009-02-21
8 posts

One more question on this library. Is it currently possible to restrict the edit functionality to the user who owns it? For example, I am a logged in user, and a member of the ‘users’ group - it would be great to edit my own profile, but not anyone else’s (like the editors and admins can).

Thanks for any thoughts
Jonathan

 
Posted: 12 November 2009 07:25 PM   [ # 73 ]   [ Rating: 0 ]
Joined: 2009-10-20
46 posts

You just have to run querys, it would be something like $this->db->where(‘user’,$this->auth->get_user);
Note: I havent search too much on this library so I can’t exactly tell the query.

 
Posted: 20 November 2009 08:12 AM   [ # 74 ]   [ Rating: 0 ]
Joined: 2009-04-15
18 posts

Hi Adam / Everyone.

Fairly new to CI and spent the morning installing the library.
Works great when using your login panel, but I am struggling a bit to implement the login on my own views.

Making my own form and logging in is no problem as long as the user is valid, but I wish to take advantage of your validation and cookie implementation in the Auth.php login method if the user credentials are invalid.

Example:-

My login form view is /home/register.
In the controller I have

function register()
{
$this
->auth->login('/photos/view');
// Other stuff

But if the login fails, I wish to return to home/register and display all the errors found in Auth.php login. I note that you have these lines

if($this->CI->form_validation->run() == FALSE)
        
{
            
if((array_key_exists('login_attempts'$_COOKIE)) && ($_COOKIE['login_attempts'>= 5))
            
{
                
echo $this->CI->lang->line('max_login_attempts_error');
            
}
            
else
            
{
                $this
->view('login');
            
}
        } 

How do I successfully go back to my view with any errors instead of $this->view(‘login’)?

Thanks very much,

Moopa

 
Posted: 20 November 2009 10:38 AM   [ # 75 ]   [ Rating: 0 ]
Joined: 2009-04-15
18 posts

I worked it out by simply removing the else clause to load the view.

 
5 of 10
5