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
f050f773
Commit
f050f773
authored
May 01, 2012
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring some auth code.
parent
de7046cc
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
46 deletions
+38
-46
auth.php
application/config/auth.php
+13
-0
eloquent.php
laravel/auth/drivers/eloquent.php
+7
-23
fluent.php
laravel/auth/drivers/fluent.php
+18
-23
No files found.
application/config/auth.php
View file @
f050f773
...
@@ -18,6 +18,19 @@ return array(
...
@@ -18,6 +18,19 @@ return array(
'driver'
=>
'eloquent'
,
'driver'
=>
'eloquent'
,
/*
|--------------------------------------------------------------------------
| Authentication Username
|--------------------------------------------------------------------------
|
| Here you may specify the database column that should be considered the
| "username" for your users. Typically, this will either be "usenrame"
| or "email". Of course, you're free to change the value to anything.
|
*/
'username'
=>
'email'
,
/*
/*
|--------------------------------------------------------------------------
|--------------------------------------------------------------------------
| Authentication Model
| Authentication Model
...
...
laravel/auth/drivers/eloquent.php
View file @
f050f773
<?php
namespace
Laravel\Auth\Drivers
;
use
User
,
Laravel\Hash
;
<?php
namespace
Laravel\Auth\Drivers
;
use
Laravel\Hash
,
Laravel\Config
;
class
Eloquent
extends
Driver
{
class
Eloquent
extends
Driver
{
/**
* The name of the "User" model used by the application.
*
* @var string
*/
public
$model
;
/**
* Create a new Eloquent authentication driver.
*
* @param string $model
* @return void
*/
public
function
__construct
(
$model
)
{
$this
->
model
=
$model
;
parent
::
__construct
();
}
/**
/**
* Get the current user of the application.
* Get the current user of the application.
*
*
...
@@ -46,7 +26,9 @@ class Eloquent extends Driver {
...
@@ -46,7 +26,9 @@ class Eloquent extends Driver {
*/
*/
public
function
attempt
(
$arguments
=
array
())
public
function
attempt
(
$arguments
=
array
())
{
{
$user
=
$this
->
model
()
->
where
(
'email'
,
'='
,
$arguments
[
'email'
])
->
first
();
$username
=
Config
::
get
(
'auth.username'
);
$user
=
$this
->
model
()
->
where
(
$username
,
'='
,
$arguments
[
'username'
])
->
first
();
// This driver uses a basic username and password authentication scheme
// This driver uses a basic username and password authentication scheme
// so if the credentials match what is in the database we will just
// so if the credentials match what is in the database we will just
...
@@ -68,7 +50,9 @@ class Eloquent extends Driver {
...
@@ -68,7 +50,9 @@ class Eloquent extends Driver {
*/
*/
protected
function
model
()
protected
function
model
()
{
{
return
new
$this
->
model
;
$model
=
Config
::
get
(
'auth.model'
);
return
new
$model
;
}
}
}
}
\ No newline at end of file
laravel/auth/drivers/fluent.php
View file @
f050f773
<?php
namespace
Laravel\Auth\Drivers
;
use
Laravel\Hash
,
Laravel\Database
;
<?php
namespace
Laravel\Auth\Drivers
;
use
Laravel\Hash
,
Laravel\Database
as
DB
;
class
Fluent
extends
Driver
{
class
Fluent
extends
Driver
{
/**
* The "users" table used by the application.
*
* @var string
*/
public
$table
;
/**
* Create a new fluent authentication driver.
*
* @param string $table
* @return void
*/
public
function
__construct
(
$table
)
{
$this
->
table
=
$table
;
parent
::
__construct
();
}
/**
/**
* Get the current user of the application.
* Get the current user of the application.
*
*
...
@@ -34,7 +14,7 @@ class Fluent extends Driver {
...
@@ -34,7 +14,7 @@ class Fluent extends Driver {
{
{
if
(
filter_var
(
$id
,
FILTER_VALIDATE_INT
)
!==
false
)
if
(
filter_var
(
$id
,
FILTER_VALIDATE_INT
)
!==
false
)
{
{
D
atabase
::
table
(
$this
->
table
)
->
find
(
$id
);
D
B
::
table
(
Config
::
get
(
'auth.table'
)
)
->
find
(
$id
);
}
}
}
}
...
@@ -46,7 +26,7 @@ class Fluent extends Driver {
...
@@ -46,7 +26,7 @@ class Fluent extends Driver {
*/
*/
public
function
attempt
(
$arguments
=
array
())
public
function
attempt
(
$arguments
=
array
())
{
{
$user
=
Database
::
table
(
$this
->
table
)
->
where_email
(
$arguments
[
'email'
])
->
first
(
);
$user
=
$this
->
get_user
(
$arguments
[
'username'
]
);
// This driver uses a basic username and password authentication scheme
// This driver uses a basic username and password authentication scheme
// so if the credentials mmatch what is in the database we will just
// so if the credentials mmatch what is in the database we will just
...
@@ -61,4 +41,19 @@ class Fluent extends Driver {
...
@@ -61,4 +41,19 @@ class Fluent extends Driver {
return
false
;
return
false
;
}
}
/**
* Get the user from the database table by username.
*
* @param mixed $value
* @return mixed
*/
protected
function
get_user
(
$value
)
{
$table
=
Config
::
get
(
'auth.table'
);
$username
=
Config
::
get
(
'auth.username'
);
return
DB
::
table
(
$table
)
->
where
(
$username
,
'='
,
$value
)
->
first
();
}
}
}
\ 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