Commit 7da5feae authored by Jacob Priddy's avatar Jacob Priddy 👌
Browse files

get middleware and admin login reidrection setup prperly

parent a0363c55
<?php
namespace App\Http\Controllers\Web\Admin;
use App\Http\Controllers\Controller;
class HomeController extends Controller
{
}
<?php
namespace App\Http\Controllers\Web\Admin;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
class LoginController extends Controller
{
use AuthenticatesUsers;
}
......@@ -14,6 +14,7 @@ use Illuminate\Auth\Middleware\RequirePassword;
use Illuminate\Http\Middleware\SetCacheHeaders;
use Illuminate\Session\Middleware\StartSession;
use App\Http\Middleware\CheckForMaintenanceMode;
use App\Http\Middleware\RedirectIfAuthenticated;
use Illuminate\Routing\Middleware\ThrottleRequests;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
use Illuminate\Routing\Middleware\ValidateSignature;
......@@ -87,10 +88,9 @@ class Kernel extends HttpKernel
'bindings' => SubstituteBindings::class,
'cache.headers' => SetCacheHeaders::class,
'can' => Authorize::class,
'password.confirm' => RequirePassword::class,
'signed' => ValidateSignature::class,
'throttle' => ThrottleRequests::class,
'verified' => EnsureEmailIsVerified::class,
'ajax' => AddAjaxHeader::class,
'guest' => RedirectIfAuthenticated::class,
];
}
......@@ -15,6 +15,10 @@ class Authenticate extends Middleware
protected function redirectTo($request): ?string
{
if (! $request->expectsJson()) {
if ($request->routeIs('web.admin.*')) {
return route('web.admin.login');
}
return route('saml.login');
}
......
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Auth;
class RedirectIfAuthenticated
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->check()) {
return redirect(route('web.index'));
}
return $next($request);
}
}
......@@ -97,7 +97,7 @@ class RouteServiceProvider extends ServiceProvider
*/
protected function mapFrontendRoutes(): void
{
Route::middleware(['web', 'auth:api'])
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/frontend.php'));
}
......
@import url(https://fonts.googleapis.com/css?family=Nunito);@charset "UTF-8";
@charset "UTF-8";
/*!
* Bootstrap v4.5.0 (https://getbootstrap.com/)
......
// Fonts
@import url('https://fonts.googleapis.com/css?family=Nunito');
//@import url('https://fonts.googleapis.com/css?family=Nunito');
// Bootstrap
@import '~bootstrap/scss/bootstrap';
......
@extends('layouts.auth')
@section('title', 'Login')
@section('main-content')
<div class="container">
<div class="row justify-content-center">
......@@ -7,11 +9,11 @@
<div class="card o-hidden border-0 shadow-lg my-5">
<div class="card-body p-0">
<div class="row">
<div class="col-lg-6 d-none d-lg-block bg-password-image"></div>
<div class="col-lg-6 d-none d-lg-block bg-login-image"></div>
<div class="col-lg-6">
<div class="p-5">
<div class="text-center">
<h1 class="h4 text-gray-900 mb-4">{{ __('Reset Password') }}</h1>
<h1 class="h4 text-gray-900 mb-4">{{ __('Login') }}</h1>
</div>
@if ($errors->any())
......@@ -24,13 +26,11 @@
</div>
@endif
<form method="POST" action="{{ route('password.update') }}" class="user">
<form method="POST" action="{{ route('login') }}" class="user">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<input type="hidden" name="token" value="{{ $token }}">
<div class="form-group">
<input type="email" class="form-control form-control-user" name="email" placeholder="{{ __('E-Mail Address') }}" value="{{ $email ?? old('email') }}" required autofocus>
<input type="email" class="form-control form-control-user" name="email" placeholder="{{ __('E-Mail Address') }}" value="{{ old('email') }}" required autofocus>
</div>
<div class="form-group">
......@@ -38,15 +38,20 @@
</div>
<div class="form-group">
<input type="password" class="form-control form-control-user" name="password_confirmation" placeholder="{{ __('Confirm Password') }}" required>
<button type="submit" class="btn btn-primary btn-user btn-block">
{{ __('Login') }}
</button>
</div>
<hr>
<div class="form-group">
<button type="submit" class="btn btn-primary btn-user btn-block">
{{ __('Reset Password') }}
</button>
<a href="{{ route('saml.login') }}" role="button" class="btn btn-github btn-user btn-block">
<i class="fab fa-github fa-fw"></i> Login with WWU
</a>
</div>
</form>
</div>
</div>
</div>
......
@extends('layouts.auth')
@section('main-content')
<div class="container">
<div class="row justify-content-center">
<div class="col-xl-10 col-lg-12 col-md-9">
<div class="card o-hidden border-0 shadow-lg my-5">
<div class="card-body p-0">
<div class="row">
<div class="col-lg-6 d-none d-lg-block bg-login-image"></div>
<div class="col-lg-6">
<div class="p-5">
<div class="text-center">
<h1 class="h4 text-gray-900 mb-4">{{ __('Login') }}</h1>
</div>
@if ($errors->any())
<div class="alert alert-danger border-left-danger" role="alert">
<ul class="pl-4 my-2">
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<form method="POST" action="{{ route('login') }}" class="user">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<div class="form-group">
<input type="email" class="form-control form-control-user" name="email" placeholder="{{ __('E-Mail Address') }}" value="{{ old('email') }}" required autofocus>
</div>
<div class="form-group">
<input type="password" class="form-control form-control-user" name="password" placeholder="{{ __('Password') }}" required>
</div>
<div class="form-group">
<div class="custom-control custom-checkbox small">
<input type="checkbox" class="custom-control-input" name="remember" id="remember" {{ old('remember') ? 'checked' : '' }}>
<label class="custom-control-label" for="remember">{{ __('Remember Me') }}</label>
</div>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary btn-user btn-block">
{{ __('Login') }}
</button>
</div>
<hr>
<div class="form-group">
<button type="button" class="btn btn-github btn-user btn-block">
<i class="fab fa-github fa-fw"></i> {{ __('Login with GitHub') }}
</button>
</div>
<div class="form-group">
<button type="button" class="btn btn-twitter btn-user btn-block">
<i class="fab fa-twitter fa-fw"></i> {{ __('Login with Twitter') }}
</button>
</div>
<div class="form-group">
<button type="button" class="btn btn-facebook btn-user btn-block">
<i class="fab fa-facebook-f fa-fw"></i> {{ __('Login with Facebook') }}
</button>
</div>
</form>
<hr>
@if (Route::has('password.request'))
<div class="text-center">
<a class="small" href="{{ route('password.request') }}">
{{ __('Forgot Password?') }}
</a>
</div>
@endif
@if (Route::has('register'))
<div class="text-center">
<a class="small" href="{{ route('register') }}">{{ __('Create an Account!') }}</a>
</div>
@endif
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
@extends('layouts.auth')
@section('main-content')
<div class="container">
<div class="row justify-content-center">
<div class="col-xl-10 col-lg-12 col-md-9">
<div class="card o-hidden border-0 shadow-lg my-5">
<div class="card-body p-0">
<div class="row">
<div class="col-lg-6 d-none d-lg-block bg-password-image"></div>
<div class="col-lg-6">
<div class="p-5">
<div class="text-center">
<h1 class="h4 text-gray-900 mb-4">{{ __('Confirm Password') }}</h1>
<p>{{ __('Please confirm your password before continuing.') }}</p>
</div>
@if ($errors->any())
<div class="alert alert-danger border-left-danger" role="alert">
<ul class="pl-4 my-2">
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
@if (session('status'))
<div class="alert alert-success border-left-success" role="alert">
{{ session('status') }}
</div>
@endif
<form method="POST" action="{{ route('password.confirm') }}" class="user">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<div class="form-group">
<input type="password" class="form-control form-control-user" name="password" placeholder="{{ __('Password') }}" required autocomplete="current-password">
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary btn-user btn-block">
{{ __('Confirm Password') }}
</button>
</div>
</form>
<hr>
@if (Route::has('password.request'))
<div class="text-center">
<a class="small" href="{{ route('password.request') }}">
{{ __('Forgot Password?') }}
</a>
</div>
@endif
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
@extends('layouts.auth')
@section('main-content')
<div class="container">
<div class="row justify-content-center">
<div class="col-xl-10 col-lg-12 col-md-9">
<div class="card o-hidden border-0 shadow-lg my-5">
<div class="card-body p-0">
<div class="row">
<div class="col-lg-6 d-none d-lg-block bg-password-image"></div>
<div class="col-lg-6">
<div class="p-5">
<div class="text-center">
<h1 class="h4 text-gray-900 mb-4">{{ __('Reset Password') }}</h1>
</div>
@if ($errors->any())
<div class="alert alert-danger border-left-danger" role="alert">
<ul class="pl-4 my-2">
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
@if (session('status'))
<div class="alert alert-success border-left-success" role="alert">
{{ session('status') }}
</div>
@endif
<form method="POST" action="{{ route('password.email') }}" class="user">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<div class="form-group">
<input type="email" class="form-control form-control-user" name="email" placeholder="{{ __('E-Mail Address') }}" value="{{ old('email') }}" required>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary btn-user btn-block">
{{ __('Send Password Reset Link') }}
</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
@extends('layouts.auth')
@section('main-content')
<div class="container">
<div class="row justify-content-center">
<div class="col-xl-10 col-lg-12 col-md-9">
<div class="card o-hidden border-0 shadow-lg my-5">
<div class="card-body p-0">
<div class="row">
<div class="col-lg-6 d-none d-lg-block bg-login-image"></div>
<div class="col-lg-6">
<div class="p-5">
<div class="text-center">
<h1 class="h4 text-gray-900 mb-4">{{ __('Register') }}</h1>
</div>
@if ($errors->any())
<div class="alert alert-danger border-left-danger" role="alert">
<ul class="pl-4 my-2">
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<form method="POST" action="{{ route('register') }}" class="user">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<div class="form-group">
<input type="text" class="form-control form-control-user" name="name" placeholder="{{ __('Name') }}" value="{{ old('name') }}" required autofocus>
</div>
<div class="form-group">
<input type="text" class="form-control form-control-user" name="last_name" placeholder="{{ __('Last Name') }}" value="{{ old('last_name') }}" required>
</div>
<div class="form-group">
<input type="email" class="form-control form-control-user" name="email" placeholder="{{ __('E-Mail Address') }}" value="{{ old('email') }}" required>
</div>
<div class="form-group">
<input type="password" class="form-control form-control-user" name="password" placeholder="{{ __('Password') }}" required>
</div>
<div class="form-group">
<input type="password" class="form-control form-control-user" name="password_confirmation" placeholder="{{ __('Confirm Password') }}" required>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary btn-user btn-block">
{{ __('Register') }}
</button>
</div>
</form>
<hr>
<div class="text-center">
<a class="small" href="{{ route('login') }}">
{{ __('Already have an account? Login!') }}
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
@extends('layouts.auth')
@section('main-content')
<div class="container">
<div class="row justify-content-center">
<div class="col-xl-10 col-lg-12 col-md-9">
<div class="card o-hidden border-0 shadow-lg my-5">
<div class="card-body p-0">
<div class="row">
<div class="col-lg-6 d-none d-lg-block bg-password-image"></div>
<div class="col-lg-6">
<div class="p-5">
<div class="text-center">
<h1 class="h4 text-gray-900 mb-4">{{ __('Verify Your Email Address') }}</h1>
</div>
@if (session('resent'))
<div class="alert alert-success border-left-success" role="alert">
{{ __('A fresh verification link has been sent to your email address.') }}
</div>
@endif
{{ __('Before proceeding, please check your email for a verification link.') }}
{{ __('If you did not receive the email') }}, <a href="{{ route('verification.resend') }}">{{ __('click here to request another') }}</a>.
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
......@@ -8,7 +8,7 @@
<!-- CSRF Token -->
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{{ config('app.name', 'Laravel') }}</title>
<title>Admin E-Lock - @yield('title')</title>
<!-- Fonts -->
<link href="{{ asset('vendor/fontawesome-free/css/all.min.css') }}" rel="stylesheet">
......
......@@ -2,6 +2,7 @@
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Web\MeController;
use App\Http\Controllers\Web\Admin\LoginController;
/*
|--------------------------------------------------------------------------
......@@ -10,15 +11,31 @@ use App\Http\Controllers\Web\MeController;
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
| contains the "web" middleware group. Prefix all route names in here
| with 'web' so that the api doc generator does not try to document
| them as API routes.
|
*/
Route::view('/', 'home')->name('web.index');
Route::view('/door-code', 'doorcode')->name('web.doorcode');
Route::post('/door-code', [MeController::class, 'doorcodeUpdate'])->name('web.doorcode.change');
Route::view('/password', 'password')->name('web.password');
Route::post('/password', [MeController::class, 'passwordUpdate'])->name('web.password.change');
Route::get('/access', [MeController::class, 'access'])->name('web.access');
Route::get('/tokens', [MeController::class, 'tokens'])->name('web.tokens');
Route::view('/about', 'about')->name('web.about');
Route::view('/admin/login', 'admin.auth.login')->name('web.admin.login_page')->middleware('guest:api');
Route::post('/admin/login', [LoginController::class, 'login'])->name('web.admin.login');
Route::group([
'middleware' => ['auth:api'],
], static function () {
Route::view('/', 'home')->name('web.index');
Route::view('/door-code', 'doorcode')->name('web.doorcode');
Route::post('/door-code', [MeController::class, 'doorcodeUpdate'])->name('web.doorcode.change');
Route::view('/password', 'password')->name('web.password');
Route::post('/password', [MeController::class, 'passwordUpdate'])->name('web.password.change');
Route::get('/access', [MeController::class, 'access'])->name('web.access');
Route::get('/tokens', [MeController::class, 'tokens'])->name('web.tokens');
Route::view('/about', 'about')->name('web.about');
Route::group([
'prefix' => 'admin',
], static function () {
});
});
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment