Replace laravel/ui with simplified auth
This commit is contained in:
parent
463f622d0a
commit
54dfa567d4
|
@ -1,41 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
use Inertia\Inertia;
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Login Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles authenticating users for the application and
|
||||
| redirecting them to your home screen. The controller uses a trait
|
||||
| to conveniently provide its functionality to your applications.
|
||||
|
|
||||
*/
|
||||
|
||||
use AuthenticatesUsers;
|
||||
|
||||
/**
|
||||
* Where to redirect users after login.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = RouteServiceProvider::HOME;
|
||||
|
||||
/**
|
||||
* Show the application's login form.
|
||||
*
|
||||
* @return \Inertia\Response
|
||||
*/
|
||||
public function showLoginForm()
|
||||
{
|
||||
return Inertia::render('Auth/Login');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Inertia\Inertia;
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
public function create()
|
||||
{
|
||||
return Inertia::render('Auth/Login');
|
||||
}
|
||||
|
||||
public function store()
|
||||
{
|
||||
if (Auth::attempt(Request::only('email', 'password'), Request::boolean('remember'))) {
|
||||
Session::regenerate();
|
||||
|
||||
return Redirect::intended();
|
||||
}
|
||||
|
||||
return Redirect::back()->withErrors([
|
||||
'email' => 'The provided credentials do not match our records.',
|
||||
]);
|
||||
}
|
||||
|
||||
public function destroy()
|
||||
{
|
||||
Auth::logout();
|
||||
Session::invalidate();
|
||||
Session::regenerateToken();
|
||||
|
||||
return Redirect::to('/');
|
||||
}
|
||||
}
|
|
@ -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"
|
||||
},
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -13,9 +13,8 @@
|
|||
<span class="text-sm">Remember Me</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="px-10 py-4 bg-gray-100 border-t border-gray-100 flex justify-between items-center">
|
||||
<a class="hover:underline" tabindex="-1" href="#reset-password">Forgot password?</a>
|
||||
<loading-button :loading="form.processing" class="btn-indigo" type="submit">Login</loading-button>
|
||||
<div class="px-10 py-4 bg-gray-100 border-t border-gray-100 flex">
|
||||
<loading-button :loading="form.processing" class="ml-auto btn-indigo" type="submit">Login</loading-button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
@ -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'))
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
<div slot="dropdown" class="mt-2 py-2 shadow-xl bg-white rounded text-sm">
|
||||
<inertia-link class="block px-6 py-2 hover:bg-indigo-500 hover:text-white" :href="route('users.edit', $page.props.auth.user.id)">My Profile</inertia-link>
|
||||
<inertia-link class="block px-6 py-2 hover:bg-indigo-500 hover:text-white" :href="route('users')">Manage Users</inertia-link>
|
||||
<inertia-link class="block px-6 py-2 hover:bg-indigo-500 hover:text-white w-full text-left" :href="route('logout')" method="post" as="button">Logout</inertia-link>
|
||||
<inertia-link class="block px-6 py-2 hover:bg-indigo-500 hover:text-white w-full text-left" :href="route('logout')" method="delete" as="button">Logout</inertia-link>
|
||||
</div>
|
||||
</dropdown>
|
||||
</div>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<?php
|
||||
|
||||
use App\Http\Controllers\Auth\LoginController;
|
||||
use App\Http\Controllers\ContactsController;
|
||||
use App\Http\Controllers\DashboardController;
|
||||
use App\Http\Controllers\ImagesController;
|
||||
use App\Http\Controllers\LoginController;
|
||||
use App\Http\Controllers\OrganizationsController;
|
||||
use App\Http\Controllers\ReportsController;
|
||||
use App\Http\Controllers\UsersController;
|
||||
|
@ -22,15 +22,15 @@ use Illuminate\Support\Facades\Route;
|
|||
|
||||
// Auth
|
||||
|
||||
Route::get('login', [LoginController::class, 'showLoginForm'])
|
||||
Route::get('login', [LoginController::class, 'create'])
|
||||
->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
|
||||
|
|
Loading…
Reference in New Issue