Skip to content
This repository has been archived by the owner on Nov 2, 2020. It is now read-only.

Commit

Permalink
fix(Cookies): Fix session sep from % to _
Browse files Browse the repository at this point in the history
  • Loading branch information
Rhilip committed Jul 15, 2019
1 parent 35691fc commit f3e8e3f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions apps/models/form/Auth/UserLoginForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,17 @@ public function createUserSession()
if ($exist_session_count < config('base.max_per_user_session')) {
/**
* SessionId Format:
* /^(?P<secure_login_flag>[01])\$(?P<ip_or_random_crc>[a-z0-9]{8})\$\w+$/
* /^(?P<secure_login_flag>[01])_(?P<ip_crc>[a-z0-9]{8})_\w+$/
* The first character of sessionId is the Flag of secure login,
* if secure login, The second param is the sprintf('%08x',crc32($id))
* else, Another random string with length 8
* The prefix of sessionId is in lowercase
*
*/
if ($this->securelogin === 'yes') {
$sid_prefix = '1$' . sprintf('%08x',crc32(app()->request->getClientIp())) . '$';
$sid_prefix = '1_' . sprintf('%08x', crc32(app()->request->getClientIp())) . '_';
} else {
$sid_prefix = '0$' . StringHelper::getRandomString(8) . '$';
$sid_prefix = '0_' . StringHelper::getRandomString(8) . '_';
}
$sid_prefix = strtolower($sid_prefix);
do { // To make sure this session is unique !
Expand Down Expand Up @@ -187,7 +187,8 @@ public function updateUserLoginInfo()
])->execute();
}

public function noticeUser() {
public function noticeUser()
{
// TODO send email to tail user login
}
}

0 comments on commit f3e8e3f

Please sign in to comment.