diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 762af262..b889c840 100755 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -26,16 +26,20 @@ class LoginController extends Controller return $this->view('auth/login'); } + /** + * @param Request $request + * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\View\View + */ protected function sendLoginResponse(Request $request) { - $request->session()->regenerate(); - $this->clearLoginAttempts($request); - $user = Auth::user(); // TODO: How to handle ON_LEAVE? if($user->state !== PilotState::ACTIVE) { + Log::info('Trying to login '. $user->pilot_id .', state ' + . PilotState::label($user->state)); + // Log them out $this->guard()->logout(); $request->session()->invalidate(); @@ -43,14 +47,16 @@ class LoginController extends Controller // Redirect to one of the error pages if($user->state === PilotState::PENDING) { return $this->view('auth.pending'); - } - - elseif ($user->state === PilotState::REJECTED) { + } elseif ($user->state === PilotState::REJECTED) { return $this->view('auth.rejected'); + } elseif ($user->state === PilotState::SUSPENDED) { + return $this->view('auth.suspended'); } } - return $this->authenticated($request, $this->guard()->user()) - ?: redirect()->intended($this->redirectPath()); + $request->session()->regenerate(); + $this->clearLoginAttempts($request); + + return redirect()->intended($this->redirectPath()); } } diff --git a/app/Models/User.php b/app/Models/User.php index 5b602a02..8766aba9 100755 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -55,6 +55,8 @@ class User extends Authenticatable 'flights' => 'integer', 'flight_time' => 'integer', 'balance' => 'double', + 'state' => 'integer', + 'status' => 'integer', ]; public static $rules = [ diff --git a/resources/views/layouts/default/auth/register.blade.php b/resources/views/layouts/default/auth/register.blade.php index a0978ead..eda28d90 100644 --- a/resources/views/layouts/default/auth/register.blade.php +++ b/resources/views/layouts/default/auth/register.blade.php @@ -59,6 +59,7 @@ @endif @include('layouts.default.auth.toc') +
By registering, you agree to the Term and Conditions

{!! Form::submit('Register!', ['class' => 'btn btn-primary']) !!} diff --git a/resources/views/layouts/default/auth/suspended.blade.php b/resources/views/layouts/default/auth/suspended.blade.php new file mode 100644 index 00000000..e1644794 --- /dev/null +++ b/resources/views/layouts/default/auth/suspended.blade.php @@ -0,0 +1,16 @@ +@extends('layouts.default.app') + +@section('title', 'account suspended') +@section('content') +
+
+
+
+

+ your has been suspended. please contact an administrator +

+
+
+
+
+@endsection()