You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3.6 KiB

Quck Start

Let's get started :)

First, we will load the Aauth Library into the system

$this->load->library("Aauth");

That was easy!

Now let's create two new users, Frodo and Legolas.

$this->aauth->create_user('frodo@example.com','frodopass','Frodo Baggins');
$this->aauth->create_user('legolas@example.com','legolaspass','Legolas');

We now we have two users.

OK, now we can create two groups, hobbits and elves.

$this->aauth->create_group('hobbits');
$this->aauth->create_group('elves');

Now, let's create a user with power, Gandalf (for our example, let's assume he was given the id of 12).

$this->aauth->create_user('gandalf@example.com', 'gandalfpass', 'Gandalf the Gray');

OK, now we have two groups and three users.

Let's create two permissions walk_unseen and immortality

$this->aauth->create_perm('walk_unseen');
$this->aauth->create_perm('immortality');

Ok, now let's give accesses to our groups. The Hobbits seem to have ability to walk unseen, so we will assign that privilage to them. The Elves have imortality, so we will assign that privilage to them. We will assign access with allow_group() function.

$this->aauth->allow_group('hobbits','walk_unseen');
$this->aauth->allow_group('elves','immortality');
  
  
$this->aauth->allow_group('hobbits','immortality');

Wait a minute! Hobbits should not have immortality. We need to fix this, we can use deny_group() to remove the permission.

$this->aauth->deny_group('hobbits','immortality');

Gandalf can also live forever.

$this->aauth->allow_user(12,'immortality');

Ok now let's check if Hobbits have immortality.

if($this->aauth->is_group_allowed('hobbits','immortality')){
	echo "Hobbits are immortal";
} else {
	echo "Hobbits are NOT immortal";
}

Results:

Hobbits are NOT immortal

Does Gandalf have the ability to live forever?

if($this->aauth->is_allowed(12,'immortality')){
	echo "Gandalf is immortal";
} else {
	echo "Gandalf is NOT immortal";
}

Results:

Gandalf is immortal

Since we don't accually live in Middle Earth, we are not aware of actual immortality. Alas, we must delete the permission.

$this->aauth->delete_perm('immortality');

It is gone.

Un-authenticated Users

So, how about un-authenticated users? In Aauth they are part of the public group. Let's give them permissions to travel. We will assume we already have a permission set up named travel.

$this->aauth->allow_group('public','travel');

Admin Users

What about the Admin users? The Admin user and any member of the Admin group is a superuser who had access everthing, There is no need to grant additional permissions.

User Parameters/Variables

For each user, variables can be defined as individual key/value pairs.

$this->aauth->set_user_var("key","value");

For example, if you want to store a user's phone number.

$this->aauth->set_user_var("phone","1-507-555-1234");

To retreive value you will use get_user_var():

$this->aauth->get_user_var("key");

Aauth also permits you to define System Variables. These can be which can be accesed by all users in the system.

$this->aauth->set_system_var("key","value");
$this->aauth->get_system_var("key");

Private Messages

OK, let's look at private messages. Frodo (id = 3) will send a PM to Legolas (id = 4);

$this->aauth->send_pm(3,4,'New cloaks','These new cloaks are fantastic!')

Banning users

Frodo has broke the rules and will now need to be banned from the system.

$this->aauth->ban_user(3);