Skip to content

Commit e8d5b54

Browse files
author
Emre Akay
committed
Merge pull request #37 from tswagger/master
Info and Errors (and other bug fixes) ---- Added flashdata boolean to error() and info() allowing the option for errors/messages to only remain for current page. Added clear_errors() and clear_infos() which removes all errors and infos from Aauth storage as well as flashdata storage Loaded flashdata into errors and infos on construct in order to fully utilize flashdata (as a result, keep_errors() and keep_infos() now work properly) Added boolean return value to login_fast() Remove redundant indexes from Aauth_v2.sql Removed bool return value from get_errors_array() and get_infos_array(). As "array" is in the method name, should only return array. Change should remain backwards compatible as empty array will still evaluate to "false". Fix bug in which "is_allowed" returns true if user is logged in and has access to perm_id=1 and perm is non-existant. Modified list_user_var_keys() to return an array so that it can be looped through Fixed duplicate message when sending password reset email, line 424 Modified lang-file constants to include prefix. This will help avoid collisions. Also added a few missing items to the lang-file Updated SQL file to be a bit more efficient. Modified keep_infos() and keep_errors() to include non-flash data values on optional boolean parameter.
2 parents d3617a0 + 2a83ea9 commit e8d5b54

File tree

6 files changed

+2267
-2155
lines changed

6 files changed

+2267
-2155
lines changed

README.md

Lines changed: 88 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,172 +1,183 @@
11
***
2-
Aauth is a User Authorization Library for CodeIgniter 2.x, which aims to make easy some essential jobs such as login, permissions and access operations. Despite ease of use, it has also very advanced features like private messages, groupping, access management, public access etc..
2+
Aauth is a User Authorization Library for CodeIgniter 2.x, which aims to make easy some essential jobs such as login, permissions and access operations. Despite its ease of use, it has also very advanced features like private messages, groupping, access management, and public access.
33

4-
**This is Quick Start page. After Quick Start, Take a look [detailed Documentation from wiki](https://github.com/emreakay/CodeIgniter-Aauth/wiki/_pages) to learn other great Features**
4+
**This is Quick Start page. You can also take a look at the [detailed Documentation Wiki](https://github.com/emreakay/CodeIgniter-Aauth/wiki/_pages) to learn about other great Features**
55

66
### Features
77
***
8-
* User Management and Operations (login, logout, register, vertification via e-mail, forgoten password, ban management, login ddos protection)
9-
* Group Operations (Creaing, deleting groups, membership management)
8+
* User Management and Operations (login, logout, register, verification via e-mail, forgotten password, user ban, login DDoS protection)
9+
* Group Operations (creating/deleting groups, membership management)
1010
* Admin and Public Group support (Public permissions)
11-
Permission Management (creating,deleting permissons, allow, deny groups, public permissions, permission checking)
12-
* Group Permissions
13-
* User Permissions (new)
14-
* User and System Variables (new)
15-
* Login Ddos Protection (new)
16-
* Private Messages (pm between users)
17-
* Error Mesages and Validations
11+
* Permission Management (creating/deleting permissions, allow/deny groups, public permissions, permission checking)
12+
* Group Permissions
13+
* User Permissions
14+
* User and System Variables
15+
* Login DDoS Protection
16+
* Private Messages (between users)
17+
* Error Messages and Validations
1818
* Langugage and config file support
19-
* Flexible
19+
* Flexible implementation
2020

2121
### What is new in Version 2
2222
***
2323
* User Permissions
2424
* User and System Variables
25-
* Login Ddos Protection
26-
* Some functions has changed
27-
* Some bugs fixed
25+
* Login DDoS Protection
26+
* Updated functions (check documentation for details)
27+
* Bugs fixes
2828

2929
### Migration
3030
***
31-
* if you have been using Version 1 before, take a look at [migration page from here.](https://github.com/emreakay/CodeIgniter-Aauth/wiki/1%29-Migration-from-V1).
31+
* If you are currently using Version 1, take a look at the [v1 to v2 migration page.](https://github.com/emreakay/CodeIgniter-Aauth/wiki/1%29-Migration-from-V1).
3232

3333
### Quick Start
3434
***
35-
Let's start :)
36-
Firstly we will load Aauth Library to system
35+
Let's get started :)
36+
First, we will load the Aauth Library into the system
3737
```php
3838
$this->load->library("Aauth");
3939
```
40-
41-
thats OK.
4240

43-
Now we will create 2 new users, Ali and John
41+
That was easy!
42+
43+
Now let's create two new users, `Frodo` and `Legolas`.
4444

4545
```php
46-
$this->aauth->create_user('ali@ali.com','alispass','Ali Akay');
47-
$this->aauth->create_user('john@john.com','johnspass','John Button');
46+
$this->aauth->create_user('frodo@example.com','frodopass','Frodo Baggins');
47+
$this->aauth->create_user('legolas@example.com','legolaspass','Legolas');
4848
```
4949

50-
thats it. now we have two users.
50+
We now we have two users.
5151

52-
Lets Create two group governors and commons :)
52+
OK, now we can create two groups, `hobbits` and `elves`.
5353
```php
54-
$this->aauth->create_group('governors');
55-
$this->aauth->create_group('commons');
54+
$this->aauth->create_group('hobbits');
55+
$this->aauth->create_group('elves');
5656
```
5757

58-
Then, Lets Create a User with power whic is Obama (having id=12)
58+
Now, let's create a user with power, Gandalf (for our example, let's assume he was given the `id` of 12).
5959
```php
60-
$this->aauth->create_user('[email protected]', 'pass-cia-fbi', 'Barrack Obama');
60+
$this->aauth->create_user('[email protected]', 'gandalfpass', 'Gandalf the Gray');
6161
```
6262

63-
ok now we have two groups and one user.
63+
OK, now we have two groups and three users.
6464

65-
Lets create a permissions 'incrase_tax' and 'change_government'
65+
Let's create two permissions `walk_unseen` and `immortality`
6666

6767
```php
68-
$this->aauth->create_perm('increase_tax');
69-
$this->aauth->create_perm('change_government');
68+
$this->aauth->create_perm('walk_unseen');
69+
$this->aauth->create_perm('immortality');
7070
```
7171

72-
Ok, now lets give accesses. logically 'governors' will have 'increase_tax' permission and 'commons' will have 'change_government' access.
73-
ok lets give proper access with _alow_group()_ function
72+
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.
73+
We will assign access with `allow_group()` function.
7474

7575
```php
76-
$this->aauth->allow_group('governors','increase_tax');
77-
$this->aauth->allow_group('commons','change_government');
76+
$this->aauth->allow_group('hobbits','walk_unseen');
77+
$this->aauth->allow_group('elves','immortality');
7878

7979

80-
$this->aauth->allow_group('commons','increase_tax');
80+
$this->aauth->allow_group('hobbits','immortality');
8181
```
8282

83-
Ops wait a minute. commons cannot 'increase_tax'. we need to fix it, we will use deny() to take back permission.
83+
Wait a minute! Hobbits should not have `immortality`. We need to fix this, we can use `deny()` to remove the permission.
8484

8585
```php
86-
$this->aauth->deny('commons','increase_tax');
86+
$this->aauth->deny('hobbits','immortality');
8787
```
8888

89-
Obama also can increse tax ha?
89+
Gandalf can also live forever.
9090

9191
```php
92-
$this->aauth->allow_user(12,'increase_tax');
92+
$this->aauth->allow_user(12,'immortality');
9393
```
9494

95-
96-
Ok now lets check if commons can 'increase_tax'
95+
Ok now let's check if Hobbits have `immortality`.
9796

9897
```php
99-
if($this->aauth->is_group_allowed('commons','increase_tax')){
100-
// i dont think so
98+
if($this->aauth->is_group_allowed('hobbits','immortality')){
99+
echo "Hobbits are immortal";
101100
} else {
102-
// do sth in the middle
101+
echo "Hobbits are NOT immortal";
103102
}
104-
```
103+
```
104+
Results:
105+
```
106+
Hobbits are NOT immortal
107+
```
105108

106-
Can Obama increase_tax ? Let's check it.
109+
Does Gandalf have the ability to live forever?
107110

108111
```php
109-
if($this->aauth->is_allowed(15,'increase_tax')){
110-
// i guess so
112+
if($this->aauth->is_allowed(12,'immortality')){
113+
echo "Gandalf is immortal";
111114
} else {
112-
// piece of code
115+
echo "Gandalf is NOT immortal";
113116
}
114117
```
118+
Results:
119+
```
120+
Gandalf is immortal
121+
```
115122

116-
117-
i think 'increse_tax' must have never been created. just delete it
123+
Since we don't accually live in Middle Earth, we are not aware of actual immortality. Alas, we must delete the permission.
118124

119125
```php
120-
$this->aauth->delete_perm('increase_tax');
126+
$this->aauth->delete_perm('immortality');
121127
```
122-
now better.
123-
124-
So what about public people? (public means not logged users). Can public people travel? Lets assume we have permissions namely 'travel' , of course.
128+
It is gone.
129+
130+
#### Un-authenticated Users
131+
132+
So, how about un-authenticated users? In Aauth they are part of the `public` group. Let's give them permissions to `travel`.
133+
We will assume we already have a permission set up named `travel`.
125134

126135
```php
127136
$this->aauth->allow_group('public','travel');
128137
```
138+
139+
#### Admin Users
140+
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.
129141

130-
So Admin? what can he do? He can access everthing, You dont need to give permiision ( using allow_group() or allow_user() ) him, he already has.
131-
132-
What about User Variables?
133-
for every individual user, variables can be defined as key-value.
142+
#### User Parameters/Variables
143+
For each user, variables can be defined as individual key/value pairs.
134144

135-
this is a simple example to set a variable.
136145
```php
137146
$this->aauth->set_user_var("key","value");
138147
```
139148

140-
For example if you want to keep users phones
149+
For example, if you want to store a user's phone number.
141150
```php
142-
$this->aauth->set_user_var("phone","0216 313 23 33");
151+
$this->aauth->set_user_var("phone","1-507-555-1234");
143152
```
144153

145-
to get the variable
154+
To retreive value you will use `get_user_var()`:
146155
```php
147156
$this->aauth->get_user_var("key");
148157
```
149158

150-
Aauth also permits you to define System Variables which can be accesed by every user in the system.
159+
Aauth also permits you to define System Variables. These can be which can be accesed by all users in the system.
151160
```php
152-
$this->aauth->set_system_var("key","Value");
161+
$this->aauth->set_system_var("key","value");
153162
$this->aauth->get_system_var("key");
154163
```
155164

156-
ok lets look at private messages. John (his id=3) will send pm to Ali(id=4)
165+
#### Private Messages
166+
OK, let's look at private messages. Frodo (`id` = 3) will send a PM to Legolas (`id` = 4);
157167

158168
```php
159-
$this->aauth->send_pm(3,4,'Hi bro. i need you',' can you gimme your credit card?')
169+
$this->aauth->send_pm(3,4,'New cloaks','These new cloaks are fantastic!')
160170
```
161-
162-
sorry John you will be banned :(
163171

172+
#### Banning users
173+
174+
Frodo has broke the rules and will not need to be banned from the system.
164175
```php
165176
$this->aauth->ban_user(3);
166177
```
167-
168-
Quick Start is done but thats not the end
169-
Take a look [detailed Documentation from wiki](https://github.com/emreakay/CodeIgniter-Aauth/wiki/_pages)
170178

171-
Dont forget to watch Aauth.
172-
You can also contribute and help me :)
179+
You have reached the end of the Quick Start Guide, but please take a look at the [detailed Documentation Wiki](https://github.com/emreakay/CodeIgniter-Aauth/wiki/_pages) for additional information.
180+
181+
182+
Don't forget to keep and eye on Aauth, we are constantly improving the system.
183+
You can also contribute and help me out. :)

application/config/aauth.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
<?php
2-
3-
if (!defined('BASEPATH'))
4-
exit('No direct script access allowed');
1+
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
52
/*
63
| -------------------------------------------------------------------
74
| Aauth Config
@@ -74,5 +71,5 @@
7471
);
7572

7673

77-
/* End of file autoload.php */
78-
/* Location: ./application/config/autoload.php */
74+
/* End of file aauth.php */
75+
/* Location: ./application/config/aauth.php */
Lines changed: 45 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,47 @@
11
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
22

3-
$lang['verification_subject'] = 'Account Vertification';
4-
$lang['reset'] = 'Pasword Reset';
5-
6-
// error mesages
7-
// change to your language
8-
9-
$lang['email_taken'] = 'E-mail is already taken';
10-
$lang['email_invalid'] = 'E-mail invalid';
11-
$lang['pass_invalid'] = 'Password invalid';
12-
$lang['name_invalid'] = 'Name invalid';
13-
$lang['code'] = 'Your code is: ';
14-
$lang['link'] = ' or you can copy and paste falowing link http://localhost/vert/';
15-
16-
$lang['remind'] = 'If you want to reset your password click the copy and go the link below http://localhost/reset/';
17-
$lang['new_password'] = 'Your new password is : ';
18-
19-
// no access
20-
$lang['no_access'] = 'You dont have access.';
21-
22-
//
23-
$lang['wrong'] = 'E-mail or Password is wrong.';
24-
$lang['exceeded'] = 'Login try limit exceeded.';
25-
$lang['recaptcha_not_correct'] = 'reCAPTCHA is incorrect.';
26-
$lang['no_user'] = 'User not Exist';
27-
$lang['not_verified'] = 'Please verify your account.';
28-
$lang['group_exist'] = 'Group already exists';
29-
$lang['no_group'] = 'Group doesn\'t exists';
30-
$lang['self_pm'] = 'It is not reasonable to send pm to yourself :)';
31-
$lang['no_pm'] = 'Pm not found';
32-
33-
//info
34-
$lang['already_member'] = 'User already member of group';
35-
$lang['already_perm'] = 'Permission name already existed';
3+
/* E-mail Messages */
4+
5+
// Account verification
6+
$lang['aauth_email_verification_subject'] = 'Account Verification';
7+
$lang['aauth_email_verification_code'] = 'Your verification code is: ';
8+
$lang['aauth_email_verification_link'] = " You can also click on (or copy and paste) the following link\n\nhttp://yourdomain/account/verification/";
9+
10+
// Password reset
11+
$lang['aauth_email_reset_subject'] = 'Reset Password';
12+
$lang['aauth_email_reset_link'] = "To reset your password click on (or copy and paste in your browser address bar) the link below:\n\nhttp://yourdomain/account/reset_password/";
13+
14+
// Password reset success
15+
$lang['aauth_email_reset_success_subject'] = 'Successful Pasword Reset';
16+
$lang['aauth_email_reset_success_new_password'] = 'Your password has successfully been reset. Your new password is : ';
17+
18+
19+
/* Error Messages */
20+
21+
// Account creation errors
22+
$lang['aauth_error_email_exists'] = 'Email address already exists on the system. If you forgot your password, you can click the link below.';
23+
$lang['aauth_error_username_exists'] = "Account already exists on the system with that username. Please enter a different username, or if you forgot your password, please click the link below.";
24+
$lang['aauth_error_email_invalid'] = 'Invalid e-mail address';
25+
$lang['aauth_error_password_invalid'] = 'Invalid password';
26+
$lang['aauth_error_username_invalid'] = 'Invalid Username';
27+
$lang['aauth_error_username_required'] = 'Username required';
28+
29+
// Access errors
30+
$lang['aauth_error_no_access'] = 'Sorry, you do not have access to the resource you requested.';
31+
$lang['aauth_error_login_failed'] = 'E-mail Address and Password do not match.';
32+
$lang['aauth_error_login_attempts_exceeded'] = 'You have exceeded your login attempts, your account has now been locked.';
33+
$lang['aauth_error_recaptcha_not_correct'] = 'Sorry, the reCAPTCHA text entered was incorrect.';
34+
35+
36+
// Misc. errors
37+
$lang['aauth_error_no_user'] = 'User does not exist';
38+
$lang['aauth_error_account_not_verified'] = 'Your account has not been verified. Please check your e-mail and verify your account.';
39+
$lang['aauth_error_no_group'] = 'Group does not exist';
40+
$lang['aauth_error_self_pm'] = 'It is not possible to send a Message to yourself.';
41+
$lang['aauth_error_no_pm'] = 'Private Message not found';
42+
43+
44+
/* Info messages */
45+
$lang['aauth_info_already_member'] = 'User is already member of group';
46+
$lang['aauth_info_group_exists'] = 'Group name already exists';
47+
$lang['aauth_info_perm_exists'] = 'Permission name already exists';

0 commit comments

Comments
 (0)