You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AbstractController.php 948B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: adrien.gandarias
  5. * Date: 08/04/2015
  6. * Time: 10:09
  7. */
  8. namespace App\Http\Controllers;
  9. abstract class AbstractController extends Controller
  10. {
  11. public function __construct()
  12. {
  13. header('Content-type: application/json; charset=UTF-8');
  14. }
  15. /**
  16. * Check javascript token provided to authenticate user
  17. * Either returns a User model or aborts application
  18. */
  19. public function authenticate()
  20. {
  21. //Code to check if user is authenticated or not
  22. // if ($user instanceof User)
  23. // return $user;
  24. // else
  25. \App::abort(401, 'AUTHENTICATION_REQUIRED');
  26. }
  27. public function admin()
  28. {
  29. //Code to check if authenticated as an admin or not
  30. // $user = $this->authenticate();
  31. //
  32. // if (UserService::isAdmin($user))
  33. // return $user;
  34. // else
  35. \App::abort(401, 'UNAUTHORIZED');
  36. }
  37. }