Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yeray Santana Hualde
syncEnrollments
Commits
3d2aa29d
Commit
3d2aa29d
authored
Oct 09, 2011
by
Eric Barnes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored auth remember me
parent
b6537da8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
5 deletions
+15
-5
auth.php
laravel/security/auth.php
+15
-5
No files found.
laravel/security/auth.php
View file @
3d2aa29d
...
@@ -52,13 +52,19 @@ class Auth {
...
@@ -52,13 +52,19 @@ class Auth {
$id
=
IoC
::
container
()
->
core
(
'session'
)
->
get
(
Auth
::
user_key
);
$id
=
IoC
::
container
()
->
core
(
'session'
)
->
get
(
Auth
::
user_key
);
if
(
is_null
(
$id
)
AND
!
is_null
(
$cookie
=
strrev
(
Crypter
::
decrypt
(
\Cookie
::
get
(
'remember'
)
))))
if
(
is_null
(
$id
)
AND
!
is_null
(
$cookie
=
Crypter
::
decrypt
(
\Cookie
::
get
(
'remember'
))))
{
{
$cookie
=
explode
(
'|'
,
$cookie
);
$cookie
=
explode
(
'|'
,
$cookie
);
if
(
$cookie
[
2
]
==
md5
(
\Request
::
server
(
'HTTP_USER_AGENT'
)))
if
(
$cookie
[
2
]
==
md5
(
\Request
::
server
(
'HTTP_USER_AGENT'
)))
{
{
$id
=
$cookie
[
0
];
$id
=
$cookie
[
0
];
}
}
if
(
!
is_null
(
static
::
$user
=
call_user_func
(
Config
::
get
(
'auth.user'
),
$id
)))
{
static
::
login
(
$user
);
return
static
::
$user
;
}
}
}
return
static
::
$user
=
call_user_func
(
Config
::
get
(
'auth.user'
),
$id
);
return
static
::
$user
=
call_user_func
(
Config
::
get
(
'auth.user'
),
$id
);
...
@@ -72,9 +78,11 @@ class Auth {
...
@@ -72,9 +78,11 @@ class Auth {
*
*
* @param string $username
* @param string $username
* @param string $password
* @param string $password
* @param bool $remember
* @param int $ttl - Default is one week.
* @return bool
* @return bool
*/
*/
public
static
function
attempt
(
$username
,
$password
=
null
,
$remember
=
false
)
public
static
function
attempt
(
$username
,
$password
=
null
,
$remember
=
false
,
$ttl
=
10080
)
{
{
if
(
!
is_null
(
$user
=
call_user_func
(
Config
::
get
(
'auth.attempt'
),
$username
,
$password
)))
if
(
!
is_null
(
$user
=
call_user_func
(
Config
::
get
(
'auth.attempt'
),
$username
,
$password
)))
{
{
...
@@ -122,12 +130,14 @@ class Auth {
...
@@ -122,12 +130,14 @@ class Auth {
/**
/**
* Set a cookie so that users are remembered.
* Set a cookie so that users are remembered.
*
*
* @param object $user
* @param int $ttl - Default is one week.
* @return bool
* @return bool
*/
*/
public
static
function
remember
(
$user
)
public
static
function
remember
(
$user
,
$ttl
=
10080
)
{
{
static
::
$user
=
$user
;
static
::
$user
=
$user
;
$cookie
=
Crypter
::
encrypt
(
strrev
(
$user
->
id
.
'|'
.
\Request
::
ip
()
.
'|'
.
md5
(
\Request
::
server
(
'HTTP_USER_AGENT'
))
.
'|'
.
time
()
));
$cookie
=
Crypter
::
encrypt
(
$user
->
id
.
'|'
.
\Request
::
ip
()
.
'|'
.
md5
(
\Request
::
server
(
'HTTP_USER_AGENT'
))
.
'|'
.
time
(
));
\Cookie
::
put
(
'remember'
,
$cookie
,
60
);
\Cookie
::
put
(
'remember'
,
$cookie
,
$ttl
);
}
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment