Files
spa-api/application/config/auth.php

81 lines
2.5 KiB
PHP
Raw Normal View History

2011-10-05 18:32:48 -05:00
<?php
return array(
/*
|--------------------------------------------------------------------------
| Retrieve The Current User
|--------------------------------------------------------------------------
|
2012-01-16 13:59:24 -06:00
| This closure is called by the Auth class' "user" method when trying to
| retrieve a user by the ID that is stored in their session. If you find
| the user, just return the user object, but make sure it has an "id"
| property. If you can't find the user, just return null.
2011-10-05 18:32:48 -05:00
|
2012-01-16 13:59:24 -06:00
| Of course, a simple and elegant authentication solution has already
| been provided for you using the query builder and hashing engine.
| We love making your life as easy as possible.
2011-10-05 18:32:48 -05:00
|
*/
'user' => function($id)
{
2012-01-16 13:59:24 -06:00
if (filter_var($id, FILTER_VALIDATE_INT) !== false)
{
2012-01-16 13:59:24 -06:00
return DB::table('users')->find($id);
}
2011-10-05 18:32:48 -05:00
},
/*
|--------------------------------------------------------------------------
| Authenticate User Credentials
|--------------------------------------------------------------------------
|
| This closure is called by the Auth::attempt() method when attempting to
2012-01-16 13:59:24 -06:00
| authenticate a user that is logging into your application. It's like a
| super buff bouncer to your application.
2011-10-05 18:32:48 -05:00
|
| If the provided credentials are correct, simply return an object that
2012-01-16 13:59:24 -06:00
| 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.
2011-10-05 18:32:48 -05:00
|
*/
2012-01-16 13:59:24 -06:00
'attempt' => function($username, $password)
2011-10-05 18:32:48 -05:00
{
2012-01-16 13:59:24 -06:00
$user = DB::table('users')->where_username($username)->first();
if ( ! is_null($user) and Hash::check($password, $user->password))
2011-10-05 18:32:48 -05:00
{
return $user;
2011-10-05 18:32:48 -05:00
}
},
/*
|--------------------------------------------------------------------------
2012-01-16 13:59:24 -06:00
| Logout The Current User
2011-10-05 18:32:48 -05:00
|--------------------------------------------------------------------------
|
| Here you may do anything that needs to be done when a user logs out of
| your application, such as call the logout method on a third-party API
2012-01-16 13:59:24 -06:00
| you are using for authentication or anything else you desire.
2011-10-05 18:32:48 -05:00
|
*/
'logout' => function($user) {},
/*
|--------------------------------------------------------------------------
| "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',
2011-10-05 18:32:48 -05:00
);