EllisLab text mark
Advanced Search
6 of 18
6
   
flexi auth - A user authentication library for CodeIgniter
Posted: 24 October 2012 07:36 AM   [ Ignore ]   [ # 81 ]   [ Rating: 0 ]
Joined: 2010-10-26
84 posts
haseydesign - 19 October 2012 07:56 PM

@davidinchi

Yes you were right, there was a bug with the library and IE setting login cookies on the ‘Login via Ajax’ example.
Although I could only regenerate the bug in IE and not Chrome as you suggested.
However, I’m pretty sure the fix should address any browsers that were having the same issue.

You can get the fix from the usual Github repo.
The only file that needs to be updated is ‘flexi_auth_lite_model.php’.

Thank YOU! My God it drove me crazy today wondering what the heck was going on. I could only back trace it to the Flexi auth system. Updated to as per told, and the logout bug dissappeared.

Otherwise a great library! thanks!

 
Posted: 25 October 2012 04:30 AM   [ Ignore ]   [ # 82 ]   [ Rating: 0 ]
Joined: 2012-03-08
168 posts

@Tom Vogt

The feature list on the first post of this thread should not really have included that in the text.

What it was referring to is that the sessions that data is saved to via the flexi auth library CAN be encrypted using the CI config setting $config[‘sess_encrypt_cookie’].

It was badly worded and ended up sounding misleading; since that feature is within the core of CI, it
cannot really be listed as a feature of the library. I’ve since edited it out.

——————————————————————————————————————————————

@Swedie
Thanks for the feedback man, glad to hear you got things sorted.

 

 Signature 

flexi-auth | A user authentication library for CodeIgniter.
flexi-cart | An e-commerce shopping cart library for CodeIgniter.

 
Posted: 26 October 2012 06:42 AM   [ Ignore ]   [ # 83 ]   [ Rating: 0 ]
Joined: 2012-10-10
3 posts

Hi.
I want to thank you for great work.
But really am confusing foe how to implement it.
I church the demo,and check the libs file there is different in deploy.
I need your help to deploy it, shall I create new model or used yours, if you just simplicity it as follow ,login controller,, model login for interact with database.
I just want understand it as well.
I appreciate if you put simple code here for my login controlled and model.
Thank you.

 
Posted: 26 October 2012 07:16 AM   [ Ignore ]   [ # 84 ]   [ Rating: 0 ]
Joined: 2012-03-08
168 posts

@x2blue

Here’s the most basic demo example I can come up with for the basics for logging in via the flexi-auth library.

You will still need to install the demo database table and content for the example to work.
The login details are the same as given via the demo.

Once you get these basics of the library understood, you can then progress to developing your code further with validation and user redirects based on login status - as demonstrated via the demo.

controllers/your_controller.php

class Your_controller extends CI_Controller {
 
    
function __construct() 
    
{
        parent
::__construct();

  
$this->auth = new stdClass;
  
$this->load->library('flexi_auth'); 
 
}

    
function login()
    

  
// If 'Login' form has been submited, attempt to log the user in.
  
if ($this->input->post('login_user'))
  
{
   
// Verify login data.
   
$result $this->flexi_auth->login($this->input->post('login_identity'), $this->input->post('login_password'), $this->input->post('remember_me'));

   if (
$result)
   
{
    
die('Login Successful');
   
}
   
else
   
{
    
die('Login Failed | <a href="'.$_SERVER['PHP_SELF'].'">Retry Login</a>');
   
}
  }
  
else
  
{
   $this
->load->view('login_view');
  
}
    }

views/login_view.php

<!doctype html>
<
html>
<
head>
 <
title>flexi auth login example</title>
</
head>
<
body id="login">
 <
form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
  <
label for="identity">Email or Username:</label>
  <
input type="text" id="identity" name="login_identity" value="admin@admin.com"/>
  <
hr>
  <
label for="password">Password:</label>
  <
input type="password" id="password" name="login_password" value="password123"/>
  <
hr>
  <
label for="remember_me">Remember Me:</label>
  <
input type="checkbox" id="remember_me" name="remember_me" value="1"/>
  <
hr>
  <
label for="submit">Login:</label>
  <
input type="submit" name="login_user" id="submit" value="Submit"/>
 </
form>
</
body>
</
html
 Signature 

flexi-auth | A user authentication library for CodeIgniter.
flexi-cart | An e-commerce shopping cart library for CodeIgniter.

 
Posted: 26 October 2012 07:32 AM   [ Ignore ]   [ # 85 ]   [ Rating: 0 ]
Joined: 2012-10-10
3 posts

Very thanks. Shall I used model or this enough.
And for the data base if I need to extend it using profile or other operation . I used as you mentioned or shall create a model to handle it.
Thanks

 
Posted: 26 October 2012 07:57 AM   [ Ignore ]   [ # 86 ]   [ Rating: 0 ]
Joined: 2012-03-08
168 posts

@x2blue

I’m guessing that you probably new to using CodeIgniter.
The flexi-auth libraries and models should not be edited by you at all, they should just be dropped into the correct directories and then called when required. The only file you are likely to need to edit, is the flexi-auth-config file.

Regarding how you implement your own code with either controllers or models, basically, anything that you put in a model can also be put in the controller. The purpose of the model is primarily a way to tidy your codebase so that your controllers are directing the flow of data rather than managing the functionality of getting/setting data.

Jumping straight into using a library like flexi-auth will not be easy for someone without CodeIgniter /MVC experience. I suggest you familarise yourself with the CI user guide to get a better understanding of how to do things.
When I first started learning CI, I spent a few hours just reading every page within the guide. It is so well documented it will greatly enhance your understanding of how to use the framework.

Once you understand the basics, jump back into the flexi-auth user guide and demo to get started on building your application.

 Signature 

flexi-auth | A user authentication library for CodeIgniter.
flexi-cart | An e-commerce shopping cart library for CodeIgniter.

 
Posted: 26 October 2012 08:08 AM   [ Ignore ]   [ # 87 ]   [ Rating: 0 ]
Joined: 2012-10-10
3 posts

I understand your point. But in your sample code you don’t use the model. I suppose there are two method to handle by your model or the library file.
As the file model you provide if I create login function shall I pass all data from login view to model or just is used the way you mention in the sample.
Thanks

 
Posted: 26 October 2012 08:33 AM   [ Ignore ]   [ # 88 ]   [ Rating: 0 ]
Joined: 2012-03-08
168 posts

@x2blue
When you load the flexi auth library, it loads what it needs from the flexi auth models.
Any function you wish to use from the flexi auth library, is accessed directly via the libray files; you never need to interact with the flexi-auth models, just the library files.

In the demo, a model is used to perform functions like login, however, if you prefer, you could jut include these functions within your controller.
In the example above, I have just called the flexi-auth function via the controller.

 Signature 

flexi-auth | A user authentication library for CodeIgniter.
flexi-cart | An e-commerce shopping cart library for CodeIgniter.

 
Posted: 29 October 2012 12:53 PM   [ Ignore ]   [ # 89 ]   [ Rating: 0 ]
Joined: 2011-05-10
7 posts

Hi,

I’m a fan of Ion auth and was just looking into your lib and it has great documentation and features & options.

Great Work!

Any direct idea on multiple roles for a user, though I had done it for Ion auth and may need to recode otherwise.

Thanks & regards.

 

 Signature 

RT

 
Posted: 30 October 2012 04:54 AM   [ Ignore ]   [ # 90 ]   [ Rating: 0 ]
Joined: 2012-03-08
168 posts

Hi rtan,

The library includes two features that should help you with defining user roles; user groups and user privileges.

User groups are essentially used as a general category to define the primary role of a user - for example public users, moderator users, editors, etc. - they can be assigned whatever group name that you require. Once a user is assigned to a user group, it is then possible to use functions within the library to check which group the user belongs to, and then perform actions dependent on that group - for example public users could be prevented from accessing an admin only area of the site.

This level of user access detection will likely cover most basic website requirements for user access permissions to sensitive areas of a site.
However, the larger a site gets, the more technical some of the access permissions can get.

For example, lets say within an admin only area of a site, all admin users need to be given read-only access to some sensitive data, this could be easily accomplished by just defining an ‘Admin’ user group. If then some specific admin users needed to also have write access to this same data, you can no longer rely on the ‘Admin’ user group to control access, you need to add additional permission checks. This is where the user privileges come in, we can assign the write access permissions to these specific users, without granting the access to all admin users.

By using user groups and privileges together, you can have finer control over user access rights rather than having to create multiple user groups for users potentially having very similar roles.

I hope that helps.

 Signature 

flexi-auth | A user authentication library for CodeIgniter.
flexi-cart | An e-commerce shopping cart library for CodeIgniter.

 
Posted: 30 October 2012 09:48 PM   [ Ignore ]   [ # 91 ]   [ Rating: 0 ]
Joined: 2011-05-10
7 posts

Hi,

Thanks for the quick reply.

I’m adding user role selection after login and will be needing more guidance.

 Signature 

RT

 
Posted: 31 October 2012 09:00 AM   [ Ignore ]   [ # 92 ]   [ Rating: 0 ]
Joined: 2009-09-17
9 posts

First of all, thanks for this, looks very promising.

First thing I did was change the config to suit my mysql table name conventions, which is to always use “id” as the id column, not prefixed in anyway way…

Anyway, so I do

$this->flexi_auth->insert_user('username@gmail.com''''password', array(), FALSETRUE); 

to get a username in and got the following error:

Error Number1052

Column 
'id' in where clause is ambiguous

SELECT 
`email`, `activation_tokenFROM (`user_accounts`) LEFT JOIN `user_groupsON `user_accounts`.`group_id` = `user_groups`.`idWHERE `id` = 4 GROUP BY `id`

Filename: /home/supplementdb.co.uk/htdocs/dev/models/flexi_auth_lite_model.php

Line Number
163 

Looks like your query is not specifying the table name in the group by clause.

Anyway simple fix on flexi_auth_lite_model.php line: #152

$this->db->group_by(.$this->auth->tbl_col_user_account['id']); 

to

$this->db->group_by($this->auth->tbl_user_account.'.'.$this->auth->tbl_col_user_account['id']); 
 
Posted: 31 October 2012 09:04 AM   [ Ignore ]   [ # 93 ]   [ Rating: 0 ]
Joined: 2009-09-17
9 posts

Actually it seems I’m having that issue with most of the queries. If you are going to give the ability to change the columns in the config file then the queries should really include table names to avoid the problem of ambiguous columns.

 
Posted: 31 October 2012 06:21 PM   [ Ignore ]   [ # 94 ]   [ Rating: 0 ]
Joined: 2012-03-08
168 posts

@AJReading

You make a very valid point, I’ll look into updating the library ASAP.
Thanks

 Signature 

flexi-auth | A user authentication library for CodeIgniter.
flexi-cart | An e-commerce shopping cart library for CodeIgniter.

 
Posted: 01 November 2012 04:37 AM   [ Ignore ]   [ # 95 ]   [ Rating: 0 ]
Joined: 2012-09-25
1 posts

Question : I am using your product and everything works fine. Accept..

I have a grid (Wijmo) that calls a controller to get the data.
In the constructor of the controller I have this code.

if (!$this->input->is_ajax_request()) {
  if (! $this->flexi_auth->is_logged_in())
  {
  // Set a custom error message.
    $this->flexi_auth->set_error_message(‘You must login to access your climate zones.’, TRUE);
    $this->session->set_flashdata(‘message’, $this->flexi_auth->get_messages());
    redirect(‘auth’);
  }
  }

Data is received. But after that I am automatically logged out…

What am I doing wrong ?

 

 
6 of 18
6