auth.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. return array(
  3. /*
  4. |--------------------------------------------------------------------------
  5. | Retrieve The Current User
  6. |--------------------------------------------------------------------------
  7. |
  8. | This closure is called by the Auth class' "user" method when trying to
  9. | retrieve a user by the ID that is stored in their session. If you find
  10. | the user, just return the user object, but make sure it has an "id"
  11. | property. If you can't find the user, just return null.
  12. |
  13. | Of course, a simple and elegant authentication solution has already
  14. | been provided for you using the query builder and hashing engine.
  15. | We love making your life as easy as possible.
  16. |
  17. */
  18. 'user' => function($id)
  19. {
  20. if (filter_var($id, FILTER_VALIDATE_INT) !== false)
  21. {
  22. return DB::table('users')->find($id);
  23. }
  24. },
  25. /*
  26. |--------------------------------------------------------------------------
  27. | Authenticate User Credentials
  28. |--------------------------------------------------------------------------
  29. |
  30. | This closure is called by the Auth::attempt() method when attempting to
  31. | authenticate a user that is logging into your application. It's like a
  32. | super buff bouncer to your application.
  33. |
  34. | If the provided credentials are correct, simply return an object that
  35. | represents the user being authenticated. As long as it has a property
  36. | for the "id", any object will work. If the credentials are not valid,
  37. | you don't meed to return anything.
  38. |
  39. */
  40. 'attempt' => function($username, $password)
  41. {
  42. $user = DB::table('users')->where_username($username)->first();
  43. if ( ! is_null($user) and Hash::check($password, $user->password))
  44. {
  45. return $user;
  46. }
  47. },
  48. /*
  49. |--------------------------------------------------------------------------
  50. | Logout The Current User
  51. |--------------------------------------------------------------------------
  52. |
  53. | Here you may do anything that needs to be done when a user logs out of
  54. | your application, such as call the logout method on a third-party API
  55. | you are using for authentication or anything else you desire.
  56. |
  57. */
  58. 'logout' => function($user) {},
  59. /*
  60. |--------------------------------------------------------------------------
  61. | "Remember Me" Cookie Name
  62. |--------------------------------------------------------------------------
  63. |
  64. | Here you may specify the cookie name that will be used for the cookie
  65. | that serves as the "remember me" token. Of course, a sensible default
  66. | has been set for you, so you probably don't need to change it.
  67. |
  68. */
  69. 'cookie' => 'laravel_remember',
  70. );