diff --git a/app/Http/Controllers/SessionsController.php b/app/Http/Controllers/SessionsController.php new file mode 100644 index 0000000..cc2f6bd --- /dev/null +++ b/app/Http/Controllers/SessionsController.php @@ -0,0 +1,41 @@ +validate([ + 'email' => ['required', 'exists:collectives,email'], + 'password' => ['required'] + ]); + + $remember = request()->boolean('remember'); + + if (!Auth::attempt($credentials, $remember)) { + return back()->withInput()->withErrors([ + 'email' => 'Your email could not be verified.', + 'password' => 'Your password is incorrect.', + ]); + } + + return redirect()->route('admin.dashboard')->with('success', 'Welcome back!'); + } + + public function destroy(Request $request) + { + auth()->logout(); + $request->session()->invalidate(); + $request->session()->regenerateToken(); + return redirect()->route('admin.sessions.create')->with('success', 'Goodbye!'); + } +} diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php index 704089a..b888824 100644 --- a/app/Http/Middleware/Authenticate.php +++ b/app/Http/Middleware/Authenticate.php @@ -15,7 +15,7 @@ class Authenticate extends Middleware protected function redirectTo($request) { if (! $request->expectsJson()) { - return route('login'); + return route('admin.sessions.create'); } } } diff --git a/public/css/admin/style.css b/public/css/admin/style.css index fa7daa2..41297cf 100644 --- a/public/css/admin/style.css +++ b/public/css/admin/style.css @@ -271,15 +271,24 @@ .l-nav { .l-nav__tab { flex-grow: 1; - border-right: 1px solid #7874ff; padding: 10px; display: flex; align-items: center; justify-content: center; text-decoration: none; + background: unset; + color: #7874ff; + cursor: pointer; + transition: color 0.2s; + border: none; + border-left: 1px solid #7874ff; } -.l-nav__tab:last-child { - border-right: none; +.l-nav__tab:hover { + color: #de7cff; + transition: color 0.2s; +} +.l-nav__tab:first-child { + border-left: none; } .l-page-nav { diff --git a/resources/sass/admin/_layout.scss b/resources/sass/admin/_layout.scss index bd9559a..bcfa078 100644 --- a/resources/sass/admin/_layout.scss +++ b/resources/sass/admin/_layout.scss @@ -34,15 +34,27 @@ body { .l-nav__tab { flex-grow: 1; - border-right: 1px solid $c-main; padding: 10px; - + display: flex; align-items: center; justify-content: center; text-decoration: none; - &:last-child { border-right: none; } + // log out button + background: unset; + color: $c-main; + cursor: pointer; + transition: color 0.2s; + border: none; + border-left: 1px solid $c-main; + + &:hover { + color: $c-accent; + transition: color 0.2s; + } + + &:first-child { border-left: none; } } diff --git a/resources/sass/admin/_vars.scss b/resources/sass/admin/_vars.scss index a28468a..6f0c7d8 100644 --- a/resources/sass/admin/_vars.scss +++ b/resources/sass/admin/_vars.scss @@ -64,14 +64,4 @@ $c-red: #e20000; border-color: $c-accent; background-color: $c-accent-lightest; color: $c-accent; - - // border-color: #888; - // background-color: #ddd; - // color: #888; - - // &:hover, &:focus { - // border-color: #888; - // background-color: #ddd; - // color: #888; - // } } \ No newline at end of file diff --git a/resources/views/admin/layout.blade.php b/resources/views/admin/layout.blade.php index f7f1b19..4c53a30 100644 --- a/resources/views/admin/layout.blade.php +++ b/resources/views/admin/layout.blade.php @@ -14,16 +14,20 @@ @auth @endauth diff --git a/resources/views/admin/sessions/create.blade.php b/resources/views/admin/sessions/create.blade.php new file mode 100644 index 0000000..668bce6 --- /dev/null +++ b/resources/views/admin/sessions/create.blade.php @@ -0,0 +1,33 @@ +@extends('admin.layout') + +@section('pg-title', 'Log In') + +@section('content') + +
+ +@endsection \ No newline at end of file diff --git a/resources/views/components/admin/form/destroy.blade.php b/resources/views/components/admin/form/destroy.blade.php new file mode 100644 index 0000000..0df2039 --- /dev/null +++ b/resources/views/components/admin/form/destroy.blade.php @@ -0,0 +1,28 @@ +@props([ + 'object', + 'route', + 'btnClass' => 'l-page-nav__link', + 'label' => 'Delete', + 'adminNav' => false +]) + +@php + $class = join('', array_slice(explode('\\', get_class($object)), -1)); +@endphp + + + \ No newline at end of file diff --git a/resources/views/components/admin/nav.blade.php b/resources/views/components/admin/nav.blade.php index d580bdf..5ab7d48 100644 --- a/resources/views/components/admin/nav.blade.php +++ b/resources/views/components/admin/nav.blade.php @@ -2,8 +2,8 @@ @switch ($section) @case('joined') - All Joined - Add New + All Joined + Add New @break @case('owned') diff --git a/routes/web.php b/routes/web.php index 62b4d50..efc70b4 100644 --- a/routes/web.php +++ b/routes/web.php @@ -2,6 +2,7 @@ use App\Http\Controllers\CollectiveController; use App\Http\Controllers\JoinedController; +use App\Http\Controllers\SessionsController; use Illuminate\Support\Facades\Route; /* @@ -14,15 +15,35 @@ | contains the "web" middleware group. Now create something great! | */ +Route::redirect('/fanatic', '/fanatic/login')->middleware('guest'); + Route::middleware('guest')->group(function () { - //Route::get('/', []) + Route::get('/fanatic/login', [SessionsController::class, 'create']) + ->name('admin.sessions.create'); Route::get('/fanatic/install', [CollectiveController::class, 'create']) - ->name('collectives.create'); - Route::post('/fanatic', [CollectiveController::class, 'store'])->name('collectives.store'); + ->name('admin.collectives.create'); + Route::post('/fanatic', [CollectiveController::class, 'store']) + ->name('admin.collectives.store'); }); +Route::post('/fanatic', [SessionsController::class, 'store'])->name('admin.sessions.store'); + Route::middleware('auth')->group(function () { - Route::get('/fanatic', [CollectiveController::class, 'dashboard'])->name('dashboard'); + Route::get('/fanatic', [CollectiveController::class, 'dashboard'])->name('admin.dashboard'); + Route::delete('/fanatic', [SessionsController::class, 'destroy'])->name('admin.sessions.destroy'); - Route::resource('joined', JoinedController::class); + Route::get('/fanatic/joined', [JoinedController::class, 'index']) + ->name('admin.joined.index'); + Route::get('/fanatic/joined/create', [JoinedController::class, 'create']) + ->name('admin.joined.create'); + Route::post('/fanatic/joined', [JoinedController::class, 'store']) + ->name('admin.joined.store'); + Route::get('/admin/joined/{joined}', [JoinedController::class, 'show']) + ->name('admin.joined.show'); + Route::get('/admin/joined/{joined}/edit', [JoinedController::class, 'edit']) + ->name('admin.joined.edit'); + Route::patch('/admin/joined/{joined}', [JoinedController::class, 'update']) + ->name('admin.joined.update'); + Route::delete('/admin/joined/{joined}', [JoinedController::class, 'destroy']) + ->name('admin.joined.destroy'); }); diff --git a/tests/Feature/Http/Controllers/SessionsControllerTest.php b/tests/Feature/Http/Controllers/SessionsControllerTest.php new file mode 100644 index 0000000..245c64e --- /dev/null +++ b/tests/Feature/Http/Controllers/SessionsControllerTest.php @@ -0,0 +1,22 @@ +get('/'); + + $response->assertStatus(200); + } +}