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

[eluser]bondjp[/eluser]
Hi, i'm using tank auth to register my users and it works great.
Now my problem is that i have some providers who will be on the site offering services to the users.
What do i do?:
1- Create another table for providers?
if yes, how can i integrate the login process with tank auth since they will have to login to their page and use the site.

2- Use the user_profiles table and create a new field like usertype(Enum "user","admin","provider")?

Thanks

[eluser]rip_pit[/eluser]
[quote author="bondjp" date="1267211712"]Hi, i'm using tank auth to register my users and it works great.
Now my problem is that i have some providers who will be on the site offering services to the users.
What do i do?:
1- Create another table for providers?
if yes, how can i integrate the login process with tank auth since they will have to login to their page and use the site.

2- Use the user_profiles table and create a new field like usertype(Enum "user","admin","provider")?

Thanks[/quote]

i think adding a custom field in the users table would be the easiest way but i'm still noobish with Tank auth.

[eluser]bondjp[/eluser]
[quote author="rip_pit" date="1267224855"][quote author="bondjp" date="1267211712"]Hi, i'm using tank auth to register my users and it works great.
Now my problem is that i have some providers who will be on the site offering services to the users.
What do i do?:
1- Create another table for providers?
if yes, how can i integrate the login process with tank auth since they will have to login to their page and use the site.

2- Use the user_profiles table and create a new field like usertype(Enum "user","admin","provider")?

Thanks[/quote]

i think adding a custom field in the users table would be the easiest way but i'm still noobish with Tank auth.[/quote]

You're probably right, that's the last thing i wanted to do since i have created the providers table and have some queries based on that already working.
Another thing is that i'll have to add 5-6 fields to user_profiles table and making it difficult to use..
If someone has a better idea, please tell me.
Thanks.

[eluser]rhand_ci[/eluser]
[quote author="theshiftexchange" date="1242726254"]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');
    }
}
[/quote]

Thanks for this skeleton code. I am going to try this on my first effort to make a tiny CMS using Tank Auth and your code.

[eluser]cyberbobjr[/eluser]
Hi,
[quote author="rip_pit" date="1263274930"]hi guys, first, thanks for the good work and helpful topic.

Working with tank auth, even if it works fine "out of the box" I would need some advices to go further.

I'm trying (without success) to insert tank_auth's parts into another page.

It's to say, I would want to insert (like with an include) the login_form part from tank auth into my own page (instead of having to load the auth/login existing page).

Does any of you have any clues about what's the best way to do it ?

instead of
Code:
if (!$this->tank_auth->is_logged_in())
redirect('/auth/login/');

i would want something like
Code:
if (!$this->tank_auth->is_logged_in())
//show the login form from tank auth (like with include('login_form');
//in order the user could log in from the first page, not only from auth/login

Hope someone could help coz i'm having a bad time trying to do it alone. thanx for reading Wink[/quote]
I've exactly the same question, please someone can explain us how to do that ?
Thanks you so much !
Best regards

[eluser]frogsaway[/eluser]
[quote author="cyberbobjr" date="1267895673"]Hi,
[quote author="rip_pit" date="1263274930"]hi guys, first, thanks for the good work and helpful topic.

Working with tank auth, even if it works fine "out of the box" I would need some advices to go further.

I'm trying (without success) to insert tank_auth's parts into another page.

It's to say, I would want to insert (like with an include) the login_form part from tank auth into my own page (instead of having to load the auth/login existing page).

Does any of you have any clues about what's the best way to do it ?

instead of
Code:
if (!$this->tank_auth->is_logged_in())
redirect('/auth/login/');

i would want something like
Code:
if (!$this->tank_auth->is_logged_in())
//show the login form from tank auth (like with include('login_form');
//in order the user could log in from the first page, not only from auth/login

Hope someone could help coz i'm having a bad time trying to do it alone. thanx for reading Wink[/quote]
I've exactly the same question, please someone can explain us how to do that ?
Thanks you so much !
Best regards[/quote]


I have managed it by messing around a lot with the way the controller & library work.
Basically to get it to function correctly I had to break the standard way of processing forms works in CI.

Created a new function in the library which builds the data required to generate the login form. Then messed around with a custom controller to pass the error messages etc back to the login_form view.

Serious pain to get it to work correctly.

Dave.

[eluser]cyberbobjr[/eluser]
Hi,
[quote author="frogsaway" date="1267897902"]
I have managed it by messing around a lot with the way the controller & library work.
Basically to get it to function correctly I had to break the standard way of processing forms works in CI.

Created a new function in the library which builds the data required to generate the login form. Then messed around with a custom controller to pass the error messages etc back to the login_form view.

Serious pain to get it to work correctly.

Dave.[/quote]
ouch ! seems to be hard to implement Sad
Does a auth library exist in CI which can do this (simple) job ?
Regards

[eluser]frogsaway[/eluser]
It's not that hard. Just annoying. My intention with this project was to use a lot of prebuilt code modules because I'm lazy. Instead I'vee spent the first week learning how tank_auth works and rewriting bits of it.

From what I can tell it is a limitation in the CI design/philosophy. If you want to have a form displayed by one controller, but processed by another then you need to mess around with session variables (There may be another way to do this in CI, but my experience with PHP says no).

CI form validation only works on $_POST. Which means as soon as you redirect from on controller (eg auth login failure) to another (main 'welcome' contoller) the $_POST variable gets cleared out.

So what you need to do is process the form data and store all of the results into a session variable. Then the 'welcome' controller passes it through to the login form. So all error messages, post values etc need to be collected in the auth/login controller then passed into the auth/login_form view via the welcome controller.

If you want to use all of the tank_auth config options you will also need to pass that into the form. I wrote a new function in the tank_auth library which pulled out all of the config options and passed them back to me in an array. Then called this from the welcome controller and use the array in the login_form view to generate the form layout (eg email/username, captcha etc).

It's annoying, but not rocket surgery. But with my limited experience in CI (this is my first project using it) I think it's a limitation you will encounter with all modules that uses the strict MVC design enforced by CI.

[eluser]loosetops[/eluser]
CI doesn't enforce strict MVC. In fact, it doesn't enforce MVC at all. It is just MVC guidelines.

On the TankAuth issue, go to the auth controller and copy the login method and paste it into a controller of your choice. Then you can grab the $data it sets up the view by doing return $data.

Then load login_form view. Remember you can load a view with in a view. Just remember to pass the right $data array to the login_form.

Here is an example of my common load->view setup.

In the Controller
Code:
$data['title'] = 'Settings';
$data['main_view'] = 'settings_view';
$data['options'] = $options;
$this->load->view('includes/template',$data);

Now, the includes/template is just view that loads other views like the header and footer so I never have to write that code more than once. And $data['main_view'] is the view I'm actually loading.

Here is includes/template view
Code:
<?php
$this->load->view('includes/header');
$this->load->view($main_view);
$this->load->view('includes/footer');
?>

It is small and it loads the header and footer, and whatever is passed as $data['main_view'] is loaded in the middle and it still has access to the variables in the $data array. In this example, the settings_views has access to the $options variable, and the header view uses the $title variable.

You can use the same concept to include the tank_auth login form in any view/page.

NOTE: I don't remember where I picked this little trick, but it so convenient and painless I would want to give the person who came up with it due credit.

[eluser]gstoa[/eluser]
Any suggestions for those of us who want to use Tank Auth but are forced to use PHP4?

I found one thread (http://ellislab.com/forums/viewreply/600969/) discussing a similar problem with a similar auth package.

Thanks for any advice!




Theme © iAndrew 2016 - Forum software by © MyBB