EllisLab text mark
Advanced Search
2 of 33
2
   
Tank Auth v1.0 (CI authentication library)
Posted: 19 April 2009 01:44 PM   [ # 21 ]   [ Rating: 0 ]
Joined: 2009-03-25
13 posts

Awesome. Thanks again for this library, it works like a charm smile

 Signature 

[ upbeat.no - coming soon ]

 
Posted: 19 April 2009 05:52 PM   [ # 22 ]   [ Rating: 0 ]
Avatar
Joined: 2009-04-07
52 posts

U R welcome smile Please let me know if you’ll have any problem with the library.

 
Posted: 22 April 2009 12:01 AM   [ # 23 ]   [ Rating: 0 ]
Joined: 2008-11-21
153 posts

Sounds promising although in my case I’d need roles & permissions

 
Posted: 23 April 2009 02:38 PM   [ # 24 ]   [ Rating: 0 ]
Joined: 2009-04-23
3 posts

Hello i tri tank auth with postgresql,
But i get this error

A Database Error Occurred

Error Number
:

ERREURune valeur NULL viole la contrainte NOT NULL de la colonne « user_data »

INSERT INTO 
"ci_sessions" ("session_id""ip_address""user_agent""last_activity"VALUES ('fc40d7fc1a67d070866dc3578fdd1d1f''81.247.128.65''Mozilla/5.0 (Windows; U; Windows NT 6.0; fr; rv:1.'1240510179

the columns user_data is “`user_data` text COLLATE utf8_bin NOT NULL,” normaly not null,
so i dont understand why the sql request contain no data for the field user_data.

Mayby the schema.sql is not correct in this version http://konyukhov.com/soft/tank_auth/tank_auth.zip ???

 
Posted: 24 April 2009 05:34 AM   [ # 25 ]   [ Rating: 0 ]
Avatar
Joined: 2009-04-07
52 posts

It’s strange. I took the session support from native CI code, as it written here:
http://ellislab.com/codeigniter/user-guide/libraries/sessions.html
with the same table in DB:

CREATE TABLE IF NOT EXISTS  `ci_sessions` (
session_id varchar(40) DEFAULT '0' NOT NULL,
ip_address varchar(16) DEFAULT '0' NOT NULL,
user_agent varchar(50NOT NULL,
last_activity int(10unsigned DEFAULT 0 NOT NULL,
user_data text NOT NULL,
PRIMARY KEY (session_id)
); 

When exactly this SQL error occur?

 
Posted: 24 April 2009 11:06 AM   [ # 26 ]   [ Rating: 0 ]
Joined: 2009-04-23
3 posts
Gromozeka - 24 April 2009 09:34 AM

with the same table in DB:

CREATE TABLE IF NOT EXISTS  `ci_sessions` (
session_id varchar(40) DEFAULT '0' NOT NULL,
ip_address varchar(16) DEFAULT '0' NOT NULL,
user_agent varchar(50NOT NULL,
last_activity int(10unsigned DEFAULT 0 NOT NULL,
user_data text NOT NULL,
PRIMARY KEY (session_id)
); 

When exactly this SQL error occur?

thanks for the reply
I trie to port tank auth to postgresql.
De probleme is, if i go to the page /auth/login/ . Apart of the script do this request

INSERT INTO "ci_sessions" ("session_id""ip_address""user_agent""last_activity"VALUES ('fc40d7fc1a67d070866dc3578fdd1d1f''81.247.128.65''Mozilla/5.0 (Windows; U; Windows NT 6.0; fr; rv:1.'1240510179

as you can see there is only 4 fields in the sql request. But on the schema there are 5 field for test i have change the schema like this

CREATE TABLE IF NOT EXISTS  `ci_sessions` (
session_id varchar(40) DEFAULT '0' NOT NULL,
ip_address varchar(16) DEFAULT '0' NOT NULL,
user_agent varchar(50NOT NULL,
last_activity int(10unsigned DEFAULT 0 NOT NULL,
user_data text ,
PRIMARY KEY (session_id)
); 

that work but i dont know if that change afect the tank auth script???
If you want i can post the schema of the postgresql database.

 
Posted: 25 April 2009 02:14 PM   [ # 27 ]   [ Rating: 0 ]
Avatar
Joined: 2009-04-07
52 posts

I tried to google any info about this case, but found nothing.

It seems to me that the problem is in PostgreSQL driver for CodeIgniter, in session management. Unfortunately I can’t prove it—there is no PostgreSQL on my hoster’s server.
Would you test how sessions work on PostgreSQL in your aplication regardless of Tank Auth? Does any similar error occur?

 
Posted: 26 April 2009 05:39 AM   [ # 28 ]   [ Rating: 0 ]
Joined: 2009-04-23
3 posts
Gromozeka - 25 April 2009 06:14 PM

I tried to google any info about this case, but found nothing.

It seems to me that the problem is in PostgreSQL driver for CodeIgniter, in session management. Unfortunately I can’t prove it—there is no PostgreSQL on my hoster’s server.
Would you test how sessions work on PostgreSQL in your aplication regardless of Tank Auth? Does any similar error occur?

I think is very dificult to port to postgresql, because postgresql is realy different with mysql for exemple no unix time function in postgresql.

For testing i have install mysql to see the demo of tank auth.
I can create a account.
I recive de mail for validation.
I can validate de account.
I can login without capcha.
I can logout
I can login with capcha

include thank auth to my aplication?
I try like this, tell my if it is correct?

class Welcome extends Controller {

    
function Welcome()
    
{
        parent
::Controller();    
        
$this->load->config('tank_auth'TRUE);
        
$this->load->helper(array('form''url'));
        
$this->load->library('form_validation');
        
$this->load->library('tank_auth');
        
$this->lang->load('tank_auth');
    
}
    
    
function index()
    
{   
        
if ($this->tank_auth->is_logged_in())  
        

            $this
->load->view('welcome_message');
        
}  
         
else  
        
{  
             redirect
('/auth/login/'); 
        
}  
    }

It is possible to manage users role with tank auth ???
If it is not possible, can you tell my the way to extend the thank auth with role and or profile for users?

 
Posted: 28 April 2009 10:21 AM   [ # 29 ]   [ Rating: 0 ]
Avatar
Joined: 2009-04-07
52 posts
keiser1080 - 26 April 2009 09:39 AM

I try like this, tell my if it is correct?

class Welcome extends Controller {

    
function Welcome()
    
{
        parent
::Controller();    
        
$this->load->config('tank_auth'TRUE);
        
$this->load->helper(array('form''url'));
        
$this->load->library('form_validation');
        
$this->load->library('tank_auth');
        
$this->lang->load('tank_auth');
    
}
    
    
function index()
    
{   
        
if ($this->tank_auth->is_logged_in())  
        

            $this
->load->view('welcome_message');
        
}  
         
else  
        
{  
             redirect
('/auth/login/'); 
        
}  
    }

It is possible to manage users role with tank auth ???
If it is not possible, can you tell my the way to extend the thank auth with role and or profile for users?

Yes, it’s correct. Also you can use get_username (or get_user_id) method to identify user when he/she is logged in.

Role management isn’t supported in this version. I think that role management shouldn’t be a part of authorisation library. Maybe there will be an extension for the lib, to manage user rights, give them access to different pages and moderate their profiles… But definitely it is not a direction in which I’m going to develop the library right now. I’d better add OpenId support to extend login options.

What about user profiles—they are supported already. To add new fields to user profile you have to:
- add corresponding fields to user_profiles table in database
- create a page for editing this data by registered user.

This edit page is supposed to be added in next version of the library. smile

 
Posted: 29 April 2009 11:48 AM   [ # 30 ]   [ Rating: 0 ]
Avatar
Joined: 2006-07-13
1 posts

Hi!

What would be the best way to localize/change urls when using TankAuth.

I would like to have
http://mydomain.com/auth/login/ changed to http://mydomain.com/konto/zaloguj

I can use routes facility, but Auth class redirects to “auth/*” methods on certain events.
I would like also to keep original code of TankAuth.

Regards,
Maciek

 
Posted: 29 April 2009 06:38 PM   [ # 31 ]   [ Rating: 0 ]
Avatar
Joined: 2009-04-07
52 posts

Why don’t you change the controller code according to your needs?

When I was developing the library I supposed that ‘auth’ controller is a part that will be modified from one project to another. It is just a sample; many libraries are being distributed without such controller at all. So if its behavior doesn’t safisfy you then you’re free to change it. For example, if you don’t want user to be redirected to server root after successful login, just change this redirect in ‘login’ method to something else.

While correcting controller behavior is easy, changing names of controller’s methods may be a little bit complicated. If you want to change the name of ‘login’ method, don’t forget to correct it in all redirects to login (or at least to change this code to something else). Renaming other methods (such as ‘activate’ or ‘reset_password’) requires you to fix corresponding email templates also.

And renaming controller leads to fixing names in all view-files and redirects. Or you may use CI routing.

I don’t know is it possible to resolve this problem without touching the controller at all, using some tricks like remap functions or Redirect commands in htaccess-file. As for me, the best way is to change the code than to build struts. smile

 
Posted: 03 May 2009 07:19 PM   [ # 32 ]   [ Rating: 0 ]
Avatar
Joined: 2009-04-07
52 posts

Hi guys,

New version of the library (Tank Auth 1.0.3) is available. The download link is the same:
http://konyukhov.com/soft/tank_auth/tank_auth.zip

There are no new features in this version, only minor bug fixes. The database structure is not affected, all the changes were in the code, in the folders ‘libraries’, ‘models’ and ‘views’.


PS: I can’t explain why they made

empty("0"

returning TRUE, but they did it. Did you know that? Me neither.

 
Posted: 06 May 2009 03:14 PM   [ # 33 ]   [ Rating: 0 ]
Avatar
Joined: 2007-07-14
171 posts

Hi,

I keep getting “Registration is disabled.” even though I set $config[‘allow_registration’] = TRUE;

 Signature 

Hell Horror - CodeIgniter Community for Horror Movie Fans

 
Posted: 06 May 2009 06:03 PM   [ # 34 ]   [ Rating: 0 ]
Avatar
Joined: 2009-04-07
52 posts

Could you post your instances of config/tank_auth.php and controllers/auth.php?

 
Posted: 06 May 2009 06:12 PM   [ # 35 ]   [ Rating: 0 ]
Avatar
Joined: 2007-07-14
171 posts

Auth

function register()
    
{
        
if ($this->tank_auth->is_logged_in()) {                                    // logged in
            
redirect('');

        
elseif ($this->tank_auth->is_logged_in(FALSE)) {                        // logged in, not activated
            
redirect('/auth/send_again/');

        
elseif (!$this->config->item('allow_registration''tank_auth')) {    // registration is off
            
$this->_show_message($this->lang->line('auth_message_registration_disabled'));
            return;

        
else {
            $use_username 
$this->config->item('use_username''tank_auth');
            if (
$use_username{
                $this
->form_validation->set_rules('username''Username''trim|required|xss_clean|min_length['.$this->config->item('username_min_length''tank_auth').']|max_length['.$this->config->item('username_max_length''tank_auth').']|alpha_dash');
            
}
            $this
->form_validation->set_rules('email''Email''trim|required|xss_clean|valid_email');
            
$this->form_validation->set_rules('password''Password''trim|required|xss_clean|min_length['.$this->config->item('password_min_length''tank_auth').']|max_length['.$this->config->item('password_max_length''tank_auth').']|alpha_dash');
            
$this->form_validation->set_rules('confirm_password''Confirm Password''trim|required|xss_clean|matches[password]');

            
$captcha_registration    $this->config->item('captcha_registration''tank_auth');
            
$use_recaptcha            $this->config->item('use_recaptcha''tank_auth');
            if (
$captcha_registration{
                
if ($use_recaptcha{
                    $this
->form_validation->set_rules('recaptcha_response_field''Confirmation Code''trim|xss_clean|required|callback__check_recaptcha');
                
else {
                    $this
->form_validation->set_rules('captcha''Confirmation Code''trim|xss_clean|required|callback__check_captcha');
                
}
            }
            $data[
'errors'= array();

            
$email_activation $this->config->item('email_activation''tank_auth');

            if (
$this->form_validation->run()) {                                // validation ok
                
if (!is_null($data $this->tank_auth->create_user(
                        
$use_username $this->form_validation->set_value('username') : '',
                        
$this->form_validation->set_value('email'),
                        
$this->form_validation->set_value('password'),
                        
$email_activation))) {                                    // success

                    
$data['site_name'$this->config->item('website_name''tank_auth');

                    if (
$email_activation{                                    // send "activate" email
                        
$data['activation_period'$this->config->item('email_activation_expire''tank_auth') / 3600;

                        
$this->_send_email('activate'$data['email']$data);

                        unset(
$data['password']); // Clear password (just for any case)

                        
$this->_show_message($this->lang->line('auth_message_registration_completed_1'));
                        return;

                    
else {
                        
if ($this->config->item('email_account_details''tank_auth')) {    // send "welcome" email

                            
$this->_send_email('welcome'$data['email']$data);
                        
}
                        
unset($data['password']); // Clear password (just for any case)

                        
$this->_show_message($this->lang->line('auth_message_registration_completed_2').' '.anchor(site_url('/auth/login/'), 'Login'));
                        return;
                    
}
                } 
else {
                    $errors 
$this->tank_auth->get_error_message();
                    foreach (
$errors as $k => $v)    $data['errors'][$k] $this->lang->line($v);
                
}
            }
            
if ($captcha_registration{
                
if ($use_recaptcha{
                    $data[
'recaptcha_html'$this->_create_recaptcha();
                
else {
                    $data[
'captcha_html'$this->_create_captcha();
                
}
            }
            $data[
'use_username'$use_username;
            
$data['captcha_registration'$captcha_registration;
            
$data['use_recaptcha'$use_recaptcha;
            
$this->load->view('auth/register_form'$data);
        
}
    } 

tank_auth

$config['allow_registration'TRUE;
$config['captcha_registration'FALSE;
$config['email_activation'FALSE;
$config['email_activation_expire'60*60*24*2;
$config['email_account_details'TRUE;
$config['use_username'TRUE
 Signature 

Hell Horror - CodeIgniter Community for Horror Movie Fans

 
2 of 33
2