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
6178a968
Commit
6178a968
authored
Oct 10, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #110 from ericbarnes/feature/remember_me
Feature/remember me
parents
b7b5451a
6e0d69e2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
2 deletions
+31
-2
auth.php
laravel/security/auth.php
+31
-2
No files found.
laravel/security/auth.php
View file @
6178a968
...
...
@@ -52,7 +52,19 @@ class Auth {
$id
=
IoC
::
container
()
->
core
(
'session'
)
->
get
(
Auth
::
user_key
);
return
static
::
$user
=
call_user_func
(
Config
::
get
(
'auth.user'
),
$id
);
static
::
$user
=
call_user_func
(
Config
::
get
(
'auth.user'
),
$id
);
if
(
is_null
(
static
::
$user
)
AND
!
is_null
(
$cookie
=
Crypter
::
decrypt
(
\Cookie
::
get
(
'remember'
))))
{
$cookie
=
explode
(
'|'
,
$cookie
);
if
(
$cookie
[
2
]
==
md5
(
\Request
::
server
(
'HTTP_USER_AGENT'
))
AND
!
is_null
(
static
::
$user
=
call_user_func
(
Config
::
get
(
'auth.user'
),
$cookie
[
0
])))
{
static
::
login
(
static
::
$user
);
}
}
return
static
::
$user
;
}
/**
...
...
@@ -63,14 +75,18 @@ class Auth {
*
* @param string $username
* @param string $password
* @param bool $remember
* @param int $ttl - Default is one week.
* @return bool
*/
public
static
function
attempt
(
$username
,
$password
=
null
)
public
static
function
attempt
(
$username
,
$password
=
null
,
$remember
=
false
,
$ttl
=
10080
)
{
if
(
!
is_null
(
$user
=
call_user_func
(
Config
::
get
(
'auth.attempt'
),
$username
,
$password
)))
{
static
::
login
(
$user
);
if
(
$remember
)
static
::
remember
(
$user
);
return
true
;
}
...
...
@@ -108,4 +124,17 @@ class Auth {
IoC
::
container
()
->
core
(
'session'
)
->
forget
(
Auth
::
user_key
);
}
/**
* Set a cookie so that users are remembered.
*
* @param object $user
* @param int $ttl - Default is one week.
* @return bool
*/
public
static
function
remember
(
$user
,
$ttl
=
10080
)
{
static
::
$user
=
$user
;
$cookie
=
Crypter
::
encrypt
(
implode
(
'|'
,
array
(
$user
->
id
,
\Request
::
ip
(),
md5
(
\Request
::
server
(
'HTTP_USER_AGENT'
)),
time
())));
\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