Skip to content

Commit 1458422

Browse files
committed
Merge branch '2' of github.com:benedmunds/CodeIgniter-Ion-Auth into 2
2 parents 0c26028 + 23437d8 commit 1458422

File tree

4 files changed

+58
-14
lines changed

4 files changed

+58
-14
lines changed

config/ion_auth.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
$config['email_activation'] = FALSE; // Email Activation for registration
9292
$config['manual_activation'] = FALSE; // Manual Activation for registration
9393
$config['remember_users'] = TRUE; // Allow users to be remembered and enable auto-login
94-
$config['user_expire'] = 86500; // How long to remember the user (seconds)
94+
$config['user_expire'] = 86500; // How long to remember the user (seconds). Set to zero for no expiration
9595
$config['user_extend_on_login'] = FALSE; // Extend the users cookies everytime they auto-login
9696
$config['track_login_attempts'] = FALSE; // Track the number of failed login attempts for each user or ip.
9797
$config['maximum_login_attempts'] = 3; // The maximum number of failed login attempts.

models/ion_auth_model.php

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,10 +1427,21 @@ public function set_lang($lang = 'en')
14271427
{
14281428
$this->trigger_events('set_lang');
14291429

1430+
// if the user_expire is set to zero we'll set the expiration two years from now.
1431+
if($this->config->item('user_expire', 'ion_auth') === 0)
1432+
{
1433+
$expire = (60*60*24*365*2);
1434+
}
1435+
// otherwise use what is set
1436+
else
1437+
{
1438+
$expire = $this->config->item('user_expire', 'ion_auth');
1439+
}
1440+
14301441
set_cookie(array(
14311442
'name' => 'lang_code',
14321443
'value' => $lang,
1433-
'expire' => $this->config->item('user_expire', 'ion_auth') + time()
1444+
'expire' => $expire
14341445
));
14351446

14361447
return TRUE;
@@ -1459,16 +1470,27 @@ public function remember_user($id)
14591470

14601471
if ($this->db->affected_rows() > -1)
14611472
{
1473+
// if the user_expire is set to zero we'll set the expiration two years from now.
1474+
if($this->config->item('user_expire', 'ion_auth') === 0)
1475+
{
1476+
$expire = (60*60*24*365*2);
1477+
}
1478+
// otherwise use what is set
1479+
else
1480+
{
1481+
$expire = $this->config->item('user_expire', 'ion_auth');
1482+
}
1483+
14621484
set_cookie(array(
14631485
'name' => 'identity',
14641486
'value' => $user->{$this->identity_column},
1465-
'expire' => $this->config->item('user_expire', 'ion_auth'),
1487+
'expire' => $expire
14661488
));
14671489

14681490
set_cookie(array(
14691491
'name' => 'remember_code',
14701492
'value' => $salt,
1471-
'expire' => $this->config->item('user_expire', 'ion_auth'),
1493+
'expire' => $expire
14721494
));
14731495

14741496
$this->trigger_events(array('post_remember_user', 'remember_user_successful'));

models/ion_auth_mongodb_model.php

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1620,12 +1620,23 @@ public function set_lang($lang = 'en')
16201620
{
16211621
$this->trigger_events('set_lang');
16221622

1623+
// if the user_expire is set to zero we'll set the expiration two years from now.
1624+
if($this->config->item('user_expire', 'ion_auth') === 0)
1625+
{
1626+
$expire = (60*60*24*365*2);
1627+
}
1628+
// otherwise use what is set
1629+
else
1630+
{
1631+
$expire = $this->config->item('user_expire', 'ion_auth');
1632+
}
1633+
16231634
set_cookie(array(
16241635
'name' => 'lang_code',
16251636
'value' => $lang,
1626-
'expire' => $this->config->item('user_expire', 'ion_auth') + time(),
1637+
'expire' => $expire
16271638
));
1628-
1639+
16291640
return TRUE;
16301641
}
16311642

@@ -1636,7 +1647,7 @@ public function set_lang($lang = 'en')
16361647
*
16371648
* @return bool
16381649
*/
1639-
private function remember_user($id)
1650+
public function remember_user($id)
16401651
{
16411652
$this->trigger_events('pre_remember_user');
16421653

@@ -1658,16 +1669,27 @@ private function remember_user($id)
16581669
// Set cookies
16591670
if ($updated)
16601671
{
1672+
// if the user_expire is set to zero we'll set the expiration two years from now.
1673+
if($this->config->item('user_expire', 'ion_auth') === 0)
1674+
{
1675+
$expire = (60*60*24*365*2);
1676+
}
1677+
// otherwise use what is set
1678+
else
1679+
{
1680+
$expire = $this->config->item('user_expire', 'ion_auth');
1681+
}
1682+
16611683
set_cookie(array(
1662-
'name' => 'identity',
1663-
'value' => $user->{$this->identity_column},
1664-
'expire' => $this->config->item('user_expire', 'ion_auth'),
1684+
'name' => 'identity',
1685+
'value' => $user->{$this->identity_column},
1686+
'expire' => $expire
16651687
));
16661688

16671689
set_cookie(array(
1668-
'name' => 'remember_code',
1669-
'value' => $salt,
1670-
'expire' => $this->config->item('user_expire', 'ion_auth'),
1690+
'name' => 'remember_code',
1691+
'value' => $salt,
1692+
'expire' => $expire
16711693
));
16721694

16731695
$this->trigger_events(array('post_remember_user', 'remember_user_successful'));

userguide/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ <h3>Config</h3>
202202
<li>'max_password_length' - Maximum length of passwords. DEFAULT is '20'.</li>
203203
<li>'email_activation' - TRUE or FALSE. Sets whether to require email activation or not. DEFAULT is 'false'.</li>
204204
<li>'remember_users' - TRUE or FALSE. Sets whether to enable 'remember me' functionality or not. DEFAULT is 'true'.</li>
205-
<li>'user_expire' - Sets how long to remember the user for in seconds. DEFAULT is '86500'.</li>
205+
<li>'user_expire' - Sets how long to remember the user for in seconds. Set to zero for no expiration. DEFAULT is '86500'.</li>
206206
<li>'user_extend_on_login' - TRUE or FALSE. Extend the users session expiration on login. DEFAULT is 'false'.</li>
207207
<li>'email_type' - Email content type. DEFAULT us 'html'.</li>
208208
<li>'email_templates' - Folder where the email view templates are stored. DEFAULT is 'auth/email/'.</li>

0 commit comments

Comments
 (0)