login
This commit is contained in:
parent
08f51bf8ed
commit
86d41488fa
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class SessionController extends Controller
|
||||
{
|
||||
public function create()
|
||||
{
|
||||
return view('admin.login');
|
||||
}
|
||||
|
||||
public function store()
|
||||
{
|
||||
$validatedAttributes = request()->validate([
|
||||
'email' => ['required', 'email'],
|
||||
'password' => ['required'],
|
||||
]);
|
||||
|
||||
if( !Auth::attempt($validatedAttributes) )
|
||||
{
|
||||
throw ValidationException::withMessages(['email' => 'wrong password']);
|
||||
}
|
||||
|
||||
request()->session()->regenerate();
|
||||
|
||||
return redirect('/admin');
|
||||
}
|
||||
|
||||
public function destroy()
|
||||
{
|
||||
Auth::logout();
|
||||
|
||||
return redirect('/');
|
||||
}
|
||||
|
||||
}
|
|
@ -383,16 +383,21 @@ button
|
|||
}
|
||||
|
||||
input
|
||||
, button
|
||||
{ box-shadow : inset 0 0 0 0.125rem #ddd }
|
||||
|
||||
input
|
||||
{ width : 14rem
|
||||
, textarea
|
||||
{ box-shadow : inset 0 0 0 0.125rem #ddd
|
||||
; width : 14rem
|
||||
}
|
||||
|
||||
textarea
|
||||
{ width : 25rem
|
||||
; border-radius : 1rem
|
||||
;
|
||||
}
|
||||
|
||||
button
|
||||
{ background-color : var(--b, var( --gray ) ) }
|
||||
{ box-shadow : inset 0 0 0 0.125rem var(--true-gray)
|
||||
; background-color : var(--b, var( --gray ) )
|
||||
}
|
||||
|
||||
button:hover
|
||||
, button:focus
|
||||
|
@ -677,3 +682,6 @@ dt { justify-content: flex-end }
|
|||
|
||||
dfn[title]
|
||||
{ border-bottom: 1pt dotted var(--text) }
|
||||
|
||||
.w-30
|
||||
{ width : 30rem }
|
|
@ -0,0 +1,10 @@
|
|||
<x-layout-admin>
|
||||
|
||||
<form class="col c w-30" method="post" name="edit_form" id="edit_form">
|
||||
<input type="text" name="title" class="w-30">
|
||||
<input type="text" name="slug" class="w-30" pattern="[A-Za-z0-9-]+" required>
|
||||
<textarea name="body" class="w-30"></textarea>
|
||||
<button onclick="edit_form.submit()">save</button>
|
||||
</form>
|
||||
|
||||
</x-layout-admin>
|
|
@ -0,0 +1,3 @@
|
|||
<x-layout-admin>
|
||||
|
||||
</x-layout-admin>
|
|
@ -19,20 +19,20 @@
|
|||
</nav>
|
||||
|
||||
|
||||
{{-- <?php
|
||||
if ( $_SESSION['active']) {
|
||||
echo $slot;
|
||||
} else { ?>
|
||||
--}}
|
||||
|
||||
<form class="col c" method="post" name="login_form">
|
||||
<input type="email" name="email" placeholder="email">
|
||||
<input type="password" name="password" placeholder="password">
|
||||
@guest
|
||||
<form class="col c" method="post" name="login_form" id="login_form" action="/login">
|
||||
@csrf
|
||||
<input type="email" name="email" placeholder="email"
|
||||
:value="old('email')"
|
||||
required>
|
||||
<input type="password" name="password" placeholder="password" required>
|
||||
<button onclick="login_form.submit()">Login</button>
|
||||
</form>
|
||||
@endguest
|
||||
|
||||
@auth
|
||||
{{ $slot }}
|
||||
{{-- <?php } ?> --}}
|
||||
@endauth
|
||||
|
||||
<footer class="c">
|
||||
<form class="buttons round c" method="get" name="search_form">
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
<x-layout-admin>
|
||||
|
||||
<form>
|
||||
<input type="text" name="slug">
|
||||
<textarea name="body"></textarea>
|
||||
<input type="submit">
|
||||
</form>
|
||||
|
||||
</x-layout-admin>
|
|
@ -1,46 +1,39 @@
|
|||
<?php
|
||||
|
||||
use App\Http\Controllers\SessionController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::get('/', function () {
|
||||
return view('index');
|
||||
});
|
||||
Route::view('/', 'index');
|
||||
Route::view('/about', 'about');
|
||||
|
||||
|
||||
Route::name('about.show')->get('/about', function () {
|
||||
return view('about');
|
||||
});
|
||||
|
||||
Route::get('/graphics', function () {
|
||||
return view('graphics');
|
||||
});
|
||||
Route::get('/photos', function () {
|
||||
return view('photos');
|
||||
});
|
||||
Route::get('/comics', function () {
|
||||
return view('comics');
|
||||
});
|
||||
Route::get('/code', function () {
|
||||
return view('code');
|
||||
});
|
||||
Route::get('/notes', function () {
|
||||
return view('notes');
|
||||
});
|
||||
Route::view('/graphics', 'graphics');
|
||||
Route::view('/photos', 'photos');
|
||||
Route::view('/comics', 'comics');
|
||||
Route::view('/code', 'code');
|
||||
Route::view('/notes', 'notes');
|
||||
|
||||
|
||||
Route::name('pages.list')->get('/list', function () {
|
||||
return view('list');
|
||||
});
|
||||
Route::name('admin.new')->get('/new', function () {
|
||||
return view('edit');
|
||||
return view('admin.edit');
|
||||
});
|
||||
Route::name('admin.edit')->get('/edit/{slug}', function ($name) {
|
||||
return view('edit');
|
||||
Route::name('admin.edit')->get('/edit', function () {
|
||||
return view('admin.edit');
|
||||
});
|
||||
Route::name('admin.edit')->get('/edit/{slug}', function ($name = null) {
|
||||
return view('admin.edit');
|
||||
})->where('slug', '[A-Za-z0-9-]+');
|
||||
Route::name('admin.index')->get('/admin', function ($name = null) {
|
||||
return view('admin');
|
||||
return view('admin.index');
|
||||
});
|
||||
|
||||
Route::get('/login', [SessionController::class, 'create']);
|
||||
Route::post('/login', [SessionController::class, 'store']);
|
||||
Route::post('/logout', [SessionController::class, 'destroy']);
|
||||
|
||||
|
||||
|
||||
Route::name('page.show')->get('/{slug}', function () {
|
||||
return view('page');
|
||||
|
|
Loading…
Reference in New Issue