g
This commit is contained in:
parent
c1996a415f
commit
91bbf06126
11 changed files with 186 additions and 26 deletions
41
app/Http/Controllers/SessionsController.php
Normal file
41
app/Http/Controllers/SessionsController.php
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class SessionsController extends Controller
|
||||||
|
{
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('admin.sessions.create');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store()
|
||||||
|
{
|
||||||
|
$credentials = request()->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!');
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,7 +15,7 @@ class Authenticate extends Middleware
|
||||||
protected function redirectTo($request)
|
protected function redirectTo($request)
|
||||||
{
|
{
|
||||||
if (! $request->expectsJson()) {
|
if (! $request->expectsJson()) {
|
||||||
return route('login');
|
return route('admin.sessions.create');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -271,15 +271,24 @@ .l-nav {
|
||||||
|
|
||||||
.l-nav__tab {
|
.l-nav__tab {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
border-right: 1px solid #7874ff;
|
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
text-decoration: none;
|
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 {
|
.l-nav__tab:hover {
|
||||||
border-right: none;
|
color: #de7cff;
|
||||||
|
transition: color 0.2s;
|
||||||
|
}
|
||||||
|
.l-nav__tab:first-child {
|
||||||
|
border-left: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.l-page-nav {
|
.l-page-nav {
|
||||||
|
|
|
@ -34,15 +34,27 @@ body {
|
||||||
|
|
||||||
.l-nav__tab {
|
.l-nav__tab {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
border-right: 1px solid $c-main;
|
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
|
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
text-decoration: none;
|
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; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -64,14 +64,4 @@ $c-red: #e20000;
|
||||||
border-color: $c-accent;
|
border-color: $c-accent;
|
||||||
background-color: $c-accent-lightest;
|
background-color: $c-accent-lightest;
|
||||||
color: $c-accent;
|
color: $c-accent;
|
||||||
|
|
||||||
// border-color: #888;
|
|
||||||
// background-color: #ddd;
|
|
||||||
// color: #888;
|
|
||||||
|
|
||||||
// &:hover, &:focus {
|
|
||||||
// border-color: #888;
|
|
||||||
// background-color: #ddd;
|
|
||||||
// color: #888;
|
|
||||||
// }
|
|
||||||
}
|
}
|
|
@ -14,16 +14,20 @@
|
||||||
|
|
||||||
@auth
|
@auth
|
||||||
<nav class="l-nav">
|
<nav class="l-nav">
|
||||||
<a href="{{ route('dashboard') }}" class="l-nav__tab">
|
<a href="{{ route('admin.dashboard') }}" class="l-nav__tab">
|
||||||
<span class="l-nav__link">dashboard</span>
|
<span class="l-nav__link">dashboard</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a href="{{ route('joined.index') }}" class="l-nav__tab">
|
<a href="{{ route('admin.joined.index') }}" class="l-nav__tab">
|
||||||
<span class="l-nav__link">joined</span>
|
<span class="l-nav__link">joined</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a href="#" class="l-nav__tab"><span class="l-nav__link">owned</span></a>
|
<a href="#" class="l-nav__tab"><span class="l-nav__link">owned</span></a>
|
||||||
<a href="#" class="l-nav__tab"><span class="l-nav__link">collective</span></a>
|
<a href="#" class="l-nav__tab"><span class="l-nav__link">collective</span></a>
|
||||||
|
|
||||||
|
<x-admin.form.destroy :btnClass="'l-nav__tab'" :object="auth_collective()"
|
||||||
|
:route="'admin.sessions.destroy'" :adminNav="true"
|
||||||
|
:label="'log out'" />
|
||||||
</nav>
|
</nav>
|
||||||
@endauth
|
@endauth
|
||||||
|
|
||||||
|
|
33
resources/views/admin/sessions/create.blade.php
Normal file
33
resources/views/admin/sessions/create.blade.php
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
@extends('admin.layout')
|
||||||
|
|
||||||
|
@section('pg-title', 'Log In')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
|
||||||
|
<form action="{{ route('admin.sessions.store') }}" method="POST">
|
||||||
|
@csrf
|
||||||
|
|
||||||
|
<fieldset class="form__fieldset">
|
||||||
|
<label for="email" class="form__label">Email:</label>
|
||||||
|
<input type="email" id="email" name="email" class="form__input">
|
||||||
|
@error('email') <p class="form__error">{{ $message }}</p> @enderror
|
||||||
|
|
||||||
|
<label for="password" class="form__label">Password:</label>
|
||||||
|
<input type="password" id="password" name="password" class="form__input">
|
||||||
|
@error('password') <p class="form__error">{{ $message }}</p> @enderror
|
||||||
|
|
||||||
|
<div class="form__checkbox">
|
||||||
|
<input type="checkbox" id="remember" name="remember" value="1"
|
||||||
|
class="form__input--checkbox">
|
||||||
|
<label for="remember" class="form__label--checkbox">remember me</label>
|
||||||
|
@error('remember') <p class="form__error">{{ $message }}</p> @enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form__btns">
|
||||||
|
<input type="submit" class="form__btn" value="Submit">
|
||||||
|
<input type="reset" class="input__btn" value="Reset">
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
@endsection
|
28
resources/views/components/admin/form/destroy.blade.php
Normal file
28
resources/views/components/admin/form/destroy.blade.php
Normal file
|
@ -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
|
||||||
|
|
||||||
|
<button form="delete-{{ $class }}-{{ $object->id }}" class="{{ $btnClass }}" title="delete">
|
||||||
|
@if ($adminNav)
|
||||||
|
<span class="l-nav__link">
|
||||||
|
@endif
|
||||||
|
{{ $label }}
|
||||||
|
@if ($adminNav)
|
||||||
|
</span>
|
||||||
|
@endif
|
||||||
|
</button>
|
||||||
|
<form action="{{ route("$route", $object) }}" class="form--hidden"
|
||||||
|
id="delete-{{ $class }}-{{ $object->id }}" method="post">
|
||||||
|
|
||||||
|
@csrf
|
||||||
|
@method('DELETE')
|
||||||
|
|
||||||
|
</form>
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
@switch ($section)
|
@switch ($section)
|
||||||
@case('joined')
|
@case('joined')
|
||||||
<a href="{{ route('joined.index') }}" class="l-page-nav__link">All Joined</a>
|
<a href="{{ route('admin.joined.index') }}" class="l-page-nav__link">All Joined</a>
|
||||||
<a href="{{ route('joined.create') }}" class="l-page-nav__link">Add New</a>
|
<a href="{{ route('admin.joined.create') }}" class="l-page-nav__link">Add New</a>
|
||||||
@break
|
@break
|
||||||
@case('owned')
|
@case('owned')
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
use App\Http\Controllers\CollectiveController;
|
use App\Http\Controllers\CollectiveController;
|
||||||
use App\Http\Controllers\JoinedController;
|
use App\Http\Controllers\JoinedController;
|
||||||
|
use App\Http\Controllers\SessionsController;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -14,15 +15,35 @@
|
||||||
| contains the "web" middleware group. Now create something great!
|
| contains the "web" middleware group. Now create something great!
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
Route::redirect('/fanatic', '/fanatic/login')->middleware('guest');
|
||||||
|
|
||||||
Route::middleware('guest')->group(function () {
|
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'])
|
Route::get('/fanatic/install', [CollectiveController::class, 'create'])
|
||||||
->name('collectives.create');
|
->name('admin.collectives.create');
|
||||||
Route::post('/fanatic', [CollectiveController::class, 'store'])->name('collectives.store');
|
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::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');
|
||||||
});
|
});
|
||||||
|
|
22
tests/Feature/Http/Controllers/SessionsControllerTest.php
Normal file
22
tests/Feature/Http/Controllers/SessionsControllerTest.php
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Illuminate\Foundation\Testing\WithFaker;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class SessionsControllerTest extends TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* A basic feature test example.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function test_example()
|
||||||
|
{
|
||||||
|
$response = $this->get('/');
|
||||||
|
|
||||||
|
$response->assertStatus(200);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue