-
Notifications
You must be signed in to change notification settings - Fork 235
2) Installation and Configuration
Copy these files into your project
application/libraries/Aauth.php application/config/aauth.php application/controller/example.php
Import sql file from
sql/aauth_v2.sql
You must set up database connections from
application/config/database.php
You can also make some changes on
application/config/aauth.php
Before you stary using Aauth, you first initilize it automaticly by using autoload or manually.
$this->load->library("Aauth");
In this example we are loading Aauth from constructer, but it is better to load automatically.
Here is simple controller.
class Example extends CI_Controller {
public function __construct() {
parent::__construct();
// Your own constructor code
$this->load->library("Aauth");
}
}
Lets create a function to login. ( See User Operations for more details )
public function login() {
if ($this->aauth->login('[email protected]', 'password', true)){
echo 'OK. You are logged in';
}
}
function for creating new user (sign up)
public function create_user() {
if ( $this->aauth->create_user('[email protected]','pasword','MrAli') ){
echo 'OK. Succesful register';
} else {
echo 'Please fix the issues below';
echo $this->aauth->print_errors();
}
}
Lets create another function to allow a group for example public to access to read comments and allow mods to delete comments ( See Permissions and Access Control for more details )
public function allow() {
$this->aauth->allow('public', 'read_comment',)
$this->aauth->allow('mods', 'delete_comment',)
}
Lets check is user logged in or not
public function is_loggedin() {
if ( $this->aauth->is_loggedin() ){
echo 'OK. You are logged in';
} else {
echo 'you must login';
}
}
Ok thats it.
class Example extends CI_Controller {
public function __construct() {
parent::__construct();
// Your own constructor code
$this->load->library("Aauth");
}
public function login() {
if ($this->aauth->login('[email protected]', 'password', true)){
echo 'OK. You are logged in';
}
}
public function create_user() {
if ( $this->aauth->create_user('[email protected]','pasword','MrAli') ){
echo 'OK. Succesful register';
} else {
echo 'Please fix the issues below';
echo $this->aauth->create_user->get_errors();
}
}
public function allow() {
$this->aauth->allow('public', 'read_comment',)
$this->aauth->allow('mods', 'delete_comment',)
}
public function is_loggedin() {
if ( $this->aauth->is_loggedin() ){
echo 'OK. You are logged in';
} else {
echo 'you must login';
}
}
}
Aauth V2 Wiki created by emreakay.com