From 54dfa567d46dc2a5de7611d7c1d2df1382508e63 Mon Sep 17 00:00:00 2001 From: Jonathan Reinink Date: Mon, 10 May 2021 17:09:30 -0400 Subject: [PATCH] Replace laravel/ui with simplified auth --- app/Http/Controllers/Auth/LoginController.php | 41 ------------- app/Http/Controllers/LoginController.php | 39 ++++++++++++ composer.json | 1 - composer.lock | 61 +------------------ resources/js/Pages/Auth/Login.vue | 12 +--- resources/js/Shared/Layout.vue | 2 +- routes/web.php | 10 +-- 7 files changed, 49 insertions(+), 117 deletions(-) delete mode 100644 app/Http/Controllers/Auth/LoginController.php create mode 100644 app/Http/Controllers/LoginController.php diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php deleted file mode 100644 index 5f8b22c..0000000 --- a/app/Http/Controllers/Auth/LoginController.php +++ /dev/null @@ -1,41 +0,0 @@ -withErrors([ + 'email' => 'The provided credentials do not match our records.', + ]); + } + + public function destroy() + { + Auth::logout(); + Session::invalidate(); + Session::regenerateToken(); + + return Redirect::to('/'); + } +} diff --git a/composer.json b/composer.json index 4f05e6e..6e2ee87 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,6 @@ "inertiajs/inertia-laravel": "^0.4", "laravel/framework": "^8.40", "laravel/tinker": "^2.5", - "laravel/ui": "^2.0", "league/glide-laravel": "^1.0", "tightenco/ziggy": "^0.8.0" }, diff --git a/composer.lock b/composer.lock index 4e49108..7cf4dcc 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "3b6210b9a1903f968a3c773d9a60aad9", + "content-hash": "669badae23389c95a5f7e1890b965ae9", "packages": [ { "name": "asm89/stack-cors", @@ -1299,65 +1299,6 @@ }, "time": "2021-03-02T16:53:12+00:00" }, - { - "name": "laravel/ui", - "version": "v2.3.0", - "source": { - "type": "git", - "url": "https://github.com/laravel/ui.git", - "reference": "2ccaa3b821ea8ac7e05393b946d0578bdb46099b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/laravel/ui/zipball/2ccaa3b821ea8ac7e05393b946d0578bdb46099b", - "reference": "2ccaa3b821ea8ac7e05393b946d0578bdb46099b", - "shasum": "" - }, - "require": { - "illuminate/console": "^7.0|^8.0", - "illuminate/filesystem": "^7.0|^8.0", - "illuminate/support": "^7.0|^8.0", - "php": "^7.2.5" - }, - "require-dev": { - "mockery/mockery": "^1.0", - "phpunit/phpunit": "^8.0|^9.0" - }, - "type": "library", - "extra": { - "laravel": { - "providers": [ - "Laravel\\Ui\\UiServiceProvider" - ] - } - }, - "autoload": { - "psr-4": { - "Laravel\\Ui\\": "src/", - "Illuminate\\Foundation\\Auth\\": "auth-backend/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Taylor Otwell", - "email": "taylor@laravel.com" - } - ], - "description": "Laravel UI utilities and presets.", - "keywords": [ - "laravel", - "ui" - ], - "support": { - "issues": "https://github.com/laravel/ui/issues", - "source": "https://github.com/laravel/ui/tree/v2.3.0" - }, - "time": "2020-09-09T12:07:59+00:00" - }, { "name": "league/commonmark", "version": "1.6.1", diff --git a/resources/js/Pages/Auth/Login.vue b/resources/js/Pages/Auth/Login.vue index c3a1a6c..31680ea 100644 --- a/resources/js/Pages/Auth/Login.vue +++ b/resources/js/Pages/Auth/Login.vue @@ -13,9 +13,8 @@ Remember Me -
- Forgot password? - Login +
+ Login
@@ -45,12 +44,7 @@ export default { }, methods: { login() { - this.form - .transform(data => ({ - ...data, - remember: data.remember ? 'on' : '', - })) - .post(this.route('login.attempt')) + this.form.post(this.route('login.attempt')) }, }, } diff --git a/resources/js/Shared/Layout.vue b/resources/js/Shared/Layout.vue index a8c0e52..46a2c4a 100644 --- a/resources/js/Shared/Layout.vue +++ b/resources/js/Shared/Layout.vue @@ -28,7 +28,7 @@
My Profile Manage Users - Logout + Logout
diff --git a/routes/web.php b/routes/web.php index 714f491..eee55e5 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,9 +1,9 @@ name('login') ->middleware('guest'); -Route::post('login', [LoginController::class, 'login']) - ->name('login.attempt') +Route::post('login', [LoginController::class, 'store']) + ->name('login.store') ->middleware('guest'); -Route::post('logout', [LoginController::class, 'logout']) +Route::delete('logout', [LoginController::class, 'destroy']) ->name('logout'); // Dashboard