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
bbffa96c
Commit
bbffa96c
authored
Nov 17, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring the auth login method. allow the developer to just pass an integer.
parent
b5207ee2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
5 deletions
+22
-5
auth.php
laravel/auth.php
+22
-5
No files found.
laravel/auth.php
View file @
bbffa96c
...
...
@@ -72,6 +72,8 @@ class Auth {
static
::
$user
=
call_user_func
(
Config
::
get
(
'auth.user'
),
$id
);
// If the user was not found in the database, but a "remember me" cookie
// exists, we will attempt to recall the user based on the cookie value.
if
(
is_null
(
static
::
$user
)
and
!
is_null
(
$cookie
=
Cookie
::
get
(
Auth
::
remember_key
)))
{
static
::
$user
=
static
::
recall
(
$cookie
);
...
...
@@ -136,17 +138,32 @@ class Auth {
/**
* Log a user into the application.
*
* @param object $user
* @param bool $remember
* An object representing the user or an integer user ID may be given to the method.
* If an object is given, the object must have an "id" property containing the user
* ID as it is stored in the database.
*
* <code>
* // Login a user by passing a user object
* Auth::login($user);
*
* // Login the user with an ID of 15
* Auth::login(15);
*
* // Login a user and set a "remember me" cookie
* Auth::login($user, true);
* </code>
*
* @param object|int $user
* @param bool $remember
* @return void
*/
public
static
function
login
(
$user
,
$remember
=
false
)
{
static
::
$user
=
$user
;
$id
=
(
is_object
(
$user
))
?
$user
->
id
:
(
int
)
$user
;
if
(
$remember
)
static
::
remember
(
$
user
->
id
);
if
(
$remember
)
static
::
remember
(
$id
);
IoC
::
core
(
'session'
)
->
put
(
Auth
::
user_key
,
$
user
->
id
);
IoC
::
core
(
'session'
)
->
put
(
Auth
::
user_key
,
$id
);
}
/**
...
...
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