Skip to content
Omkar Tapale edited this page May 2, 2017 · 10 revisions

Aauth User functions.

login($identifier, $pass, $remember = FALSE, $totp_code = NULL)

Logs user into system, if remember is optional. if you set remember as TRUE, it will remember as specified time, unless it will remember just CodeIgniter's session time.

$this->aauth->login('admin@admin.com', 'password', true)

without remember

$this->aauth->login('admin@admin.com', 'password')

logout()

Clears all sessions of current user

$this->aauth->logout()

list_users($group_par = FALSE, $limit = FALSE, $offset = FALSE, $include_banneds = FALSE)

returns list of users as an object
if group_par(group_id or group_name) is given it will also include groups of users to result
You should also check Group Operations

login_fast($user_id)

logins by using only user_id

$this->aauth->login_fast(1)

is_loggedin()

checks if user logged in, returns true or false

$this->aauth->is_loggedin()

control($perm_par = false)

It is a special function which control if a current user has permission (You must see Permissions)for given permission rule to see page. $perm_parm can be id or name of rule. If user doesn't have permission, it stops the execution and shows a message (can be changed from config file) If user has permission, it updates user's last activity date-time if perm_par is not given just control user logged in or not

I recommend you to use this function inside every controller's constructor.

to control access of a user for permission rule with id 5

$this->aauth->control(5)

to control 'bla' permission

$this->aauth->control('bla')

create_user($email, $pass, $username='')

creates user, it also return created user id and sends a verification e-mail if verification is set as true from Aauth config file. (Default is false)

$this->aauth->create_user('user@example.com', 'example_pass', 'OptionalUserName')

update_user($user_id, $email = FALSE, $pass = FALSE, $username = FALSE)

Updates user by using user_id

send_verification($user_id)

send verification to user's email (Remember, create_user also sends verification using this function)
You can also crate a link to verify user. Look Aauth config file.

verify_user($user_id, $ver_code)

verifies user

reset_login_attempts($user_id)

Limits login attempt. People can do 10 login attempts per minute by default.
it can be changed from config file by changing 'try' => 10, line

You can also deactivate this by changing that line to true 'dos_protection' => true,

ban_user($user_id)

bans user

unban_user($user_id)

unban the banned user

is_banned($user_id)

returns true if user is banned, false otherwise

delete_user($user_id)

deletes user. It is not recommended !!!. I recommend to use ban_user function

user_exist_by_email($email)

if email is already in DB, returns true

user_exist_by_username($username)

if name is already in DB, returns true

user_exist_by_name($name)

if name is already in DB, returns true

remind_password($email)

send a verification code to given email if user exists

reset_password($ver_code)

resets password and sends a random password user's email

update_activity($user_id = FALSE)

Updates the user's last activity time. Remember! control function also do this job.

update_last_login($user_id = FALSE)

Updates last login time. Remember! login function also do it.

update_remember($user_id, $expression=null, $expire=null)

updates the remember time for a user, login function also use this. You don't need to use this.

get_user($user_id = FALSE)

returns user information as an object you can also use sessions

get_user_id($email=false)

returns user_id, if email parameter not given, it will return current logged in user's id.

get_user_groups($user_id = false)

returns joined groups of given user as an object
You should also check Group Operations

hash_password($pass, $userid)

Hash the password for storage in the database