Finishing up auth re-write.
This commit is contained in:
parent
60f61f318b
commit
60ab0b66e7
|
@ -4,78 +4,44 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Retrieve The Current User
|
| Default Authentication Driver
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
|
||||||
| This closure is called by the Auth class' "user" method when trying to
|
| Laravel uses a flexible driver-based system to handle authentication.
|
||||||
| retrieve a user by the ID that is stored in their session. If you find
|
| You are free to register your own drivers using the Auth::extend
|
||||||
| the user, just return the user object, but make sure it has an "id"
|
| method. Of course, a few great drivers are provided out of
|
||||||
| property. If you can't find the user, just return null.
|
| box to handle basic authentication simply and easily.
|
||||||
|
|
|
|
||||||
| Of course, a simple and elegant authentication solution has already
|
| Drivers: 'fluent', 'eloquent'.
|
||||||
| been provided for you using the query builder and hashing engine.
|
|
||||||
| We love making your life as easy as possible.
|
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'user' => function($id)
|
'driver' => 'eloquent',
|
||||||
{
|
|
||||||
if (filter_var($id, FILTER_VALIDATE_INT) !== false)
|
|
||||||
{
|
|
||||||
return DB::table('users')->find($id);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Authenticate User Credentials
|
| Authentication Model
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
|
||||||
| This closure is called by the Auth::attempt() method when attempting to
|
| When using the "eloquent" authentication driver, you may specify the
|
||||||
| authenticate a user that is logging into your application. It's like a
|
| model that should be considered the "User" model. This model will
|
||||||
| super buff bouncer to your application.
|
| be used to authenticate and load the users of your application.
|
||||||
|
|
|
||||||
| If the provided credentials are correct, simply return an object that
|
|
||||||
| represents the user being authenticated. As long as it has a property
|
|
||||||
| for the "id", any object will work. If the credentials are not valid,
|
|
||||||
| you don't meed to return anything.
|
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'attempt' => function($username, $password)
|
'model' => 'User',
|
||||||
{
|
|
||||||
$user = DB::table('users')->where_username($username)->first();
|
|
||||||
|
|
||||||
if ( ! is_null($user) and Hash::check($password, $user->password))
|
|
||||||
{
|
|
||||||
return $user;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Logout The Current User
|
| Authentication Table
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
|
||||||
| Here you may do anything that needs to be done when a user logs out of
|
| When using the "fluent" authentication driver, the database table used
|
||||||
| your application, such as call the logout method on a third-party API
|
| to load users may be specified here. This table will be used in by
|
||||||
| you are using for authentication or anything else you desire.
|
| the fluent query builder to authenticate and load your users.
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'logout' => function($user) {},
|
'table' => 'users',
|
||||||
|
|
||||||
/*
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| "Remember Me" Cookie Name
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
|
|
|
||||||
| Here you may specify the cookie name that will be used for the cookie
|
|
||||||
| that serves as the "remember me" token. Of course, a sensible default
|
|
||||||
| has been set for you, so you probably don't need to change it.
|
|
||||||
|
|
|
||||||
*/
|
|
||||||
|
|
||||||
'cookie' => 'laravel_remember',
|
|
||||||
|
|
||||||
);
|
);
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'driver' => '',
|
'driver' => 'cookie',
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
|
|
||||||
| You can even respond to more than one URI:
|
| You can even respond to more than one URI:
|
||||||
|
|
|
|
||||||
| Route::post('hello, world', function()
|
| Route::post(array('hello', 'world'), function()
|
||||||
| {
|
| {
|
||||||
| return 'Hello World!';
|
| return 'Hello World!';
|
||||||
| });
|
| });
|
||||||
|
|
|
@ -60,16 +60,6 @@ protected static function factory($driver)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Run the logout method on all active drivers.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public static function logout()
|
|
||||||
{
|
|
||||||
array_walk(static::$drivers, function($d) { $d->logout(); });
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a third-party authentication driver.
|
* Register a third-party authentication driver.
|
||||||
*
|
*
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
use Laravel\Str;
|
use Laravel\Str;
|
||||||
use Laravel\Cookie;
|
use Laravel\Cookie;
|
||||||
|
use Laravel\Config;
|
||||||
use Laravel\Session;
|
use Laravel\Session;
|
||||||
|
|
||||||
abstract class Driver {
|
abstract class Driver {
|
||||||
|
@ -184,7 +185,7 @@ protected function cookie($name, $value, $minutes)
|
||||||
|
|
||||||
extract($config);
|
extract($config);
|
||||||
|
|
||||||
Cookie::put($name, $minutes, $token, $path, $domain, $secure);
|
Cookie::put($name, $minutes, $value, $path, $domain, $secure);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue