Skip to content

Commit

Permalink
adding roles
Browse files Browse the repository at this point in the history
  • Loading branch information
mueller-berlus committed Apr 7, 2017
1 parent 314521e commit 2c5c688
Show file tree
Hide file tree
Showing 125 changed files with 2,151 additions and 1,249 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ Homestead.json
/_ide_helper_models.php
/.phpstorm.meta.php
/_ide_helper.php
/composer.lock
/composer.lock
/storage/*.key
10 changes: 10 additions & 0 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,14 @@ protected function schedule(Schedule $schedule)
// $schedule->command('inspire')
// ->hourly();
}

/**
* + * Register the Closure based commands for the application.
* + *
* + * @return void
* + */
protected function commands()
{
require base_path('routes/console.php');
}
}
8 changes: 0 additions & 8 deletions app/Events/Event.php

This file was deleted.

53 changes: 28 additions & 25 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Http\Exceptions\HttpResponseException;
use Illuminate\Session\TokenMismatchException;
use Illuminate\Validation\ValidationException;
use Symfony\Component\Debug\Exception\FlattenException;
use Symfony\Component\HttpFoundation\JsonResponse as SymfonyResponse;
Expand All @@ -28,65 +29,67 @@ class Handler extends ExceptionHandler
* @var array
*/
protected $dontReport = [
AuthenticationException::class,
AuthorizationException::class,
HttpException::class,
ModelNotFoundException::class,
ValidationException::class,
TokenMismatchException::class,
ValidationException::class
];

/**
* Report or log an exception.
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $e
* @param \Exception $exception
* @return void
*/
public function report(Exception $e)
public function report(Exception $exception)
{
parent::report($e);
parent::report($exception);
}

/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @param \Exception $exception
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
public function render($request, Exception $exception)
{
if (ob_get_status()) {
ob_end_clean();
}

if ($this->hasMiddleware('api', $request)) {
if ($e instanceof HttpResponseException) {
return $e->getResponse();
} elseif ($e instanceof ModelNotFoundException) {
$e = new NotFoundHttpException($e->getMessage(), $e);
} elseif ($e instanceof AuthenticationException) {
return $this->unauthenticated($request, $e);
} elseif ($e instanceof AuthorizationException) {
$e = new HttpException(403, $e->getMessage());
} elseif ($e instanceof ValidationException && $e->getResponse()) {
return $e->getResponse();
if ($exception instanceof HttpResponseException) {
return $exception->getResponse();
} elseif ($exception instanceof ModelNotFoundException) {
$exception = new NotFoundHttpException($exception->getMessage(), $exception);
} elseif ($exception instanceof AuthenticationException) {
return $this->unauthenticated($request, $exception);
} elseif ($exception instanceof AuthorizationException) {
$exception = new HttpException(403, $exception->getMessage());
} elseif ($exception instanceof ValidationException && $exception->getResponse()) {
return $exception->getResponse();
}

if ($this->isHttpException($e)) {
return $this->toIlluminateResponse($this->renderHttpException($e), $e);
if ($this->isHttpException($exception)) {
return $this->toIlluminateResponse($this->renderHttpException($exception), $exception);
} else {
return $this->toIlluminateResponse($this->convertExceptionToJsonResponse($e), $e);
return $this->toIlluminateResponse($this->convertExceptionToJsonResponse($exception), $exception);
}
}

if ($e instanceof AuthorizationException) {
return $this->convertAuthorizationExceptionToResponse($e);
} elseif ($e instanceof MessageException) {
return $this->convertMessageExceptionToResponse($e);
if ($exception instanceof AuthorizationException) {
return $this->convertAuthorizationExceptionToResponse($exception);
} elseif ($exception instanceof MessageException) {
return $this->convertMessageExceptionToResponse($exception);
}

return parent::render($request, $e);
return parent::render($request, $exception);
}

/**
Expand Down Expand Up @@ -115,7 +118,7 @@ protected function unauthenticated($request, AuthenticationException $exception)
return response()->json(['error' => 'Unauthenticated.'], 401);
}

return redirect()->guest('login');
return redirect()->guest(route('login'));
}

/**
Expand Down
30 changes: 30 additions & 0 deletions app/Http/Controllers/Auth/ForgotPasswordController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;

class ForgotPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset emails and
| includes a trait which assists in sending these notifications from
| your application to your users. Feel free to explore this trait.
|
*/
use SendsPasswordResetEmails;

/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
}
36 changes: 36 additions & 0 deletions app/Http/Controllers/Auth/LoginController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;

class LoginController extends Controller
{
/*
|--------------------------------------------------------------------------
| Login Controller
|--------------------------------------------------------------------------
|
| This controller handles authenticating users for the application and
| redirecting them to your home screen. The controller uses a trait
| to conveniently provide its functionality to your applications.
|
*/
use AuthenticatesUsers;
/**
* Where to redirect users after login.
*
* @var string
*/
protected $redirectTo = '/';

/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest', ['except' => 'logout']);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,66 +2,60 @@

namespace App\Http\Controllers\Auth;

use App\Models\User;
use Validator;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
use App\Models\User;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Support\Facades\Validator;

class AuthController extends Controller
class RegisterController extends Controller
{
/*
|--------------------------------------------------------------------------
| Registration & Login Controller
| Register Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users, as well as the
| authentication of existing users. By default, this controller uses
| a simple trait to add these behaviors. Why don't you explore it?
| This controller handles the registration of new users as well as their
| validation and creation. By default this controller uses a trait to
| provide this functionality without requiring any additional code.
|
*/

use AuthenticatesAndRegistersUsers {
logout as baseLogout;
}
use ThrottlesLogins;

use RegistersUsers;
/**
* Where to redirect users after login / registration.
* Where to redirect users after registration.
*
* @var string
*/
protected $redirectTo = '/';
protected $redirectTo = '/home';

/**
* Create a new authentication controller instance.
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest', ['except' => 'logout']);
$this->middleware('guest');
}

/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|confirmed|min:6',
'password' => 'required|min:6|confirmed',
]);
}

/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @param array $data
* @return User
*/
protected function create(array $data)
Expand All @@ -72,14 +66,4 @@ protected function create(array $data)
'password' => bcrypt($data['password']),
]);
}

/**
* Log the user out of the application.
*
* @return \Illuminate\Http\Response
*/
public function logout()
{
return $this->baseLogout();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ResetsPasswords;

class PasswordController extends Controller
class ResetPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
Expand All @@ -20,6 +20,13 @@ class PasswordController extends Controller

use ResetsPasswords;

/**
* Where to redirect users after resetting their password.
*
* @var string
*/
protected $redirectTo = '/';

/**
* Create a new password controller instance.
*
Expand Down
Loading

0 comments on commit 2c5c688

Please sign in to comment.