Forum

Kohana, create cust...
 
Notifications
Clear all

Kohana, create custom login script?

1 Posty
1 Users
0 Likes
1,834 Widok
0
Topic starter

using external database with custom fields

1 Answer
0
Topic starter

1. Create file application/classes/Auth/Mydriver.php
2. With content

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from('mytable')
        ->where('customLogin', '=', $username)
        ->and_where('customPassword', '=', $password)
        ->as_object()->execute()->current();
 
    if(!empty($user))
    {
        if($password == $user->customPassword)
        {
             $this->complete_login($user);
            return true;
        }
    }
    return false;
}
 
public function password($username)
{
// Return the password for the username
}
 
public function check_password($password)
{
// Check to see if the logged in user has the given password
}
 
public function logged_in($role = NULL)
{
// Check to see if the user is logged in, and if $role is set, has all roles
}
 
public function get_user($default = NULL)
{
// Get the logged in user, or return the $default if a user is not found
}
}
from('mytable')
        ->where('customLogin', '=', $username)
        ->and_where('customPassword', '=', $password)
        ->as_object()->execute()->current();

    if(!empty($user))
    {
        if($password == $user->customPassword)
        {
             $this->complete_login($user);
            return true;
        }
    }
    return false;
}

public function password($username)
{
// Return the password for the username
}

public function check_password($password)
{
// Check to see if the logged in user has the given password
}

public function logged_in($role = NULL)
{
// Check to see if the user is logged in, and if $role is set, has all roles
}

public function get_user($default = NULL)
{
// Get the logged in user, or return the $default if a user is not found
}
}

3. Edit application/config/auth and change field ’driver’ to => ’Mydriver’
4. Now, call in any controller this method

1
$success = Auth_biofinger::instance()->login($username,$password);
$success = Auth_biofinger::instance()->login($username,$password);

Odpowiedź

Author Name

Author Email

Your question *

 
Preview 0 Revisions Saved
Share: