Welcome Guest, Not a member yet? Register   Sign In
Tank Auth v1.0 (CI authentication library)
#51

[eluser]Bonyc[/eluser]
Hi Gromozeka,

Thanks for this great auth library. but can you please add user role into it? That will be really helpful as I am trying to create a site where there will be three kinds of users.

Actually, I would like to have different roles assigned to users at the time of registration itself. Also, I would like the users to be able to view or edit their respective profile data. Some hints to achieve the same will be really appreciated. Smile

Thanks again.
Bonyc
#52

[eluser]theshiftexchange[/eluser]
The Library should have "is_username_available" and "is_email_available" functions. This allows me to create callback validation checks on my forms page, which is much more user friendly.

I know the model has this for the user; but I'd prefer not to load the model just to check this, when the library does everything else I need.
#53

[eluser]theshiftexchange[/eluser]
I've created a constructor class I use for all my controllers which the user must be logged into use.

By inheriting the "securitycontroller" class in my other controllers, it means if the user tries to access ANY function in that controller, it will not let them if they are not logged in.

Here is a copy of the skeleton code for people to use:


securitycontroller.php
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class securitycontroller extends Controller
{
    function __construct()
    {
        parent::__construct();
        $this->load->config('tank_auth', TRUE);
        if (!$this->tank_auth->is_logged_in())
        {
            redirect('');
        }
    }

    function index()
    {
        redirect ('');
    }
}


whateveryoulike.php
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

require_once('securitycontroller.php');

class whateveryoulike extends securitycontroller
{
    function __construct()
    {
        parent::__construct();
    }

    function index()
    {
        redirect ('');
    }

    function somefunction()
    {
        $this->load->view('whateveryoulike_form');
    }
}
#54

[eluser]Khanh[/eluser]
Hi

I've used layout and load in autoload['libraries']. Then I've used tank auth, there is a problem:

An Error Was Encountered

Unable to load the requested file: .php

I've debugged and found that when tank auth use: $this->ci =& get_instance(); in the constructor of library.

Can you tell me what I will do for tank auth and my layout?
#55

[eluser]theshiftexchange[/eluser]
[quote author="Khanh" date="1242810929"]Hi

I've used layout and load in autoload['libraries']. Then I've used tank auth, there is a problem:

An Error Was Encountered

Unable to load the requested file: .php

I've debugged and found that when tank auth use: $this->ci =& get_instance(); in the constructor of library.

Can you tell me what I will do for tank auth and my layout?[/quote]

Have you tried to load the library normally - not via autoload? Does that work?
#56

[eluser]Gromozeka[/eluser]
[quote author="theshiftexchange" date="1242682240"]The Library should have "is_username_available" and "is_email_available" functions. This allows me to create callback validation checks on my forms page, which is much more user friendly.

I know the model has this for the user; but I'd prefer not to load the model just to check this, when the library does everything else I need.[/quote]

Are you going to implement instant form validation using AJAX-requests? Well, it makes sense.

I added these functions to the library, please download the new zip from the same location. Only lib file is affected.
#57

[eluser]Bonyc[/eluser]
Hi Gromozeka,

Can you pls give some direction on how to create roles for different users? Actually, I would like to have different roles assigned to users at the time of registration itself. Please help. Smile

Regards,
Bonyc
#58

[eluser]theshiftexchange[/eluser]
[quote author="Bonyc" date="1242896341"]Hi Gromozeka,

Can you pls give some direction on how to create roles for different users? Actually, I would like to have different roles assigned to users at the time of registration itself. Please help. Smile

Regards,
Bonyc[/quote]

Tank_Auth doesnt have 'roles' built in.

But it is easy to add them. Just use the User_profile table, and add a Roles field there. You could run queries against that field to determine if someone is allowed to do some action
#59

[eluser]Gromozeka[/eluser]
[quote author="theshiftexchange" date="1242898201"]
Tank_Auth doesnt have 'roles' built in.

But it is easy to add them. Just use the User_profile table, and add a Roles field there. You could run queries against that field to determine if someone is allowed to do some action[/quote]

Thank you for quick reply! You speak my words Smile

Tank Auth really doesn't support role management at the moment, and I don't think it will do. The best way to add roles to the library is to add a field to 'user_profiles' table or create another table (if user may have different rights to different pages) and manage it correspondingly.
#60

[eluser]Bonyc[/eluser]
Thanks theshiftexchange and Gromozeka for the fast reply. I will try this out and see if I can get this working.

Thanks again Smile

EDIT: One more question I have. Sorry if it's too dumb Sad Is the profile management feature present in this auth library or if not, is it going to be incorporated anytime soon?




Theme © iAndrew 2016 - Forum software by © MyBB