From: Vincent Vanwaelscappel Date: Fri, 19 Apr 2024 15:16:40 +0000 (+0200) Subject: wip #6872 @1.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=ab179ab81b66a3c151fbbf50d1ed2746abe1410f;p=bastide-resah.git wip #6872 @1.5 --- diff --git a/app/Http/Controllers/FluidbookController.php b/app/Http/Controllers/FluidbookController.php index 9b215a7..d3c26dd 100644 --- a/app/Http/Controllers/FluidbookController.php +++ b/app/Http/Controllers/FluidbookController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers; use App\Models\Client; +use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Validator; @@ -43,7 +44,7 @@ class FluidbookController extends Controller protected function auth() { - return response((!auth()->guest()) ? '1' : '0')->header('Content-Type', 'text/plain'); + return response((!Auth::guard('client')->guest()) ? '1' : '0')->header('Content-Type', 'text/plain'); } protected function login() diff --git a/app/Http/Controllers/LandingController.php b/app/Http/Controllers/LandingController.php index c8da257..eb866ae 100644 --- a/app/Http/Controllers/LandingController.php +++ b/app/Http/Controllers/LandingController.php @@ -13,6 +13,10 @@ class LandingController extends Controller $path = 'index.html'; } + if ($path === 'index.html' && !Auth::guard('client')->guest()) { + $path = 'home-logged.html'; + } + $relayPath = resource_path('webflow') . '/' . $path; if (str_ends_with($path, '.html')) { $html = file_get_contents($relayPath); @@ -31,12 +35,18 @@ class LandingController extends Controller 'password' => ['required'], ]); - if (Auth::attempt($credentials)) { + if (Auth::guard('client')->attempt($credentials)) { $request->session()->regenerate(); - return redirect()->intended('dashboard'); + return redirect('/'); } return back(); } + public function logout() + { + Auth::guard('client')->logout(); + return back(); + } + } diff --git a/app/Models/Client.php b/app/Models/Client.php index b4b4cb0..4de358c 100644 --- a/app/Models/Client.php +++ b/app/Models/Client.php @@ -6,6 +6,7 @@ use App\Http\Controllers\Operations\Client\Fluidbook; use App\Http\Controllers\Operations\Client\Landing; use Cubist\Backpack\Magic\Fields\Text; use Cubist\Backpack\Magic\Models\CubistMagicAuthenticatable; +use Illuminate\Support\Facades\Password; class Client extends CubistMagicAuthenticatable { @@ -19,6 +20,7 @@ class Client extends CubistMagicAuthenticatable parent::setFields(); $this->getField('enabled')->setAttribute('label', 'Activé'); + $this->getField('password')->setAttribute('can', null); $this->addField('finess', Text::class, 'Numéro FINESS', ['tab' => 'Login']); $this->addField('hospital', Text::class, 'Nom de l\'établissement', ['tab' => 'Login']); $this->addField('firstname', Text::class, 'Prénom', ['tab' => 'Login']); diff --git a/config/auth.php b/config/auth.php index 7ea1cd1..09aef64 100644 --- a/config/auth.php +++ b/config/auth.php @@ -40,6 +40,10 @@ return [ 'driver' => 'session', 'provider' => 'users', ], + 'client' => [ + 'driver' => 'session', + 'provider' => 'clients', + ], ], /* @@ -61,6 +65,11 @@ return [ 'providers' => [ 'users' => [ + 'driver' => 'eloquent', + 'model' => App\Models\User::class, + ], + + 'clients' => [ 'driver' => 'eloquent', 'model' => App\Models\Client::class, ], @@ -102,6 +111,13 @@ return [ 'expire' => 60, 'throttle' => 60, ], + + 'clients' => [ + 'provider' => 'clients', + 'table' => 'password_reset_tokens', + 'expire' => 60, + 'throttle' => 60, + ], 'backpack' => [ 'provider' => 'users', 'table' => 'password_reset_tokens', diff --git a/resources/webflow/home-logged.html b/resources/webflow/home-logged.html new file mode 100644 index 0000000..8cf1578 --- /dev/null +++ b/resources/webflow/home-logged.html @@ -0,0 +1 @@ +Voir le catalogue diff --git a/routes/api.php b/routes/api.php deleted file mode 100644 index 889937e..0000000 --- a/routes/api.php +++ /dev/null @@ -1,19 +0,0 @@ -get('/user', function (Request $request) { - return $request->user(); -}); diff --git a/routes/channels.php b/routes/channels.php deleted file mode 100644 index 1f87c11..0000000 --- a/routes/channels.php +++ /dev/null @@ -1,18 +0,0 @@ -id === (int) $id; -}); diff --git a/routes/console.php b/routes/console.php deleted file mode 100644 index e05f4c9..0000000 --- a/routes/console.php +++ /dev/null @@ -1,19 +0,0 @@ -comment(Inspiring::quote()); -})->purpose('Display an inspiring quote'); diff --git a/routes/web.php b/routes/web.php index 038f164..90cdf49 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,18 +1,19 @@ where('path', '.*'); Route::get('/catalogue_invite/{path?}', \App\Http\Controllers\CatalogController::class . '@guest')->where('path', '.*'); -//Route::get('/{path?}', \App\Http\Controllers\LandingController::class . '@catchall')->where('path', '.*'); -Route::match(['post'], '/fluidbook/signin', \App\Http\Controllers\FluidbookController::class . '@signin')->withoutMiddleware([CheckIfAdmin::class, VerifyCsrfToken::class]); -Route::match(['post'], '/fluidbook/login', \App\Http\Controllers\FluidbookController::class . '@login')->withoutMiddleware([CheckIfAdmin::class, VerifyCsrfToken::class]); -Route::match(['post'], '/fluidbook/forgotpassword', \App\Http\Controllers\FluidbookController::class . '@forgotPAssword')->withoutMiddleware([CheckIfAdmin::class, VerifyCsrfToken::class]); -Route::match(['get'], '/fluidbook/auth', \App\Http\Controllers\FluidbookController::class . '@auth')->withoutMiddleware([CheckIfAdmin::class, VerifyCsrfToken::class]); +Route::match(['post'], '/fluidbook/signin', \App\Http\Controllers\FluidbookController::class . '@signin')->withoutMiddleware([VerifyCsrfToken::class]); +Route::match(['post'], '/fluidbook/login', \App\Http\Controllers\FluidbookController::class . '@login')->withoutMiddleware([VerifyCsrfToken::class]); +Route::match(['post'], '/fluidbook/forgotpassword', \App\Http\Controllers\FluidbookController::class . '@forgotPAssword')->withoutMiddleware([VerifyCsrfToken::class]); +Route::match(['get'], '/fluidbook/auth', \App\Http\Controllers\FluidbookController::class . '@auth'); + +Route::match(['post'], '/landing/signin', \App\Http\Controllers\LandingController::class . '@signin'); +Route::match(['post'], '/landing/login', \App\Http\Controllers\LandingController::class . '@login'); +Route::match(['post'], '/landing/forgotpassword', \App\Http\Controllers\LandingController::class . '@forgotPassword'); -Route::match(['post'], '/landing/signin', \App\Http\Controllers\LandingController::class . '@signin')->withoutMiddleware([CheckIfAdmin::class]); -Route::match(['post'], '/landing/login', \App\Http\Controllers\LandingController::class . '@login')->withoutMiddleware([CheckIfAdmin::class]); -Route::match(['post'], '/landing/forgotpassword', \App\Http\Controllers\LandingController::class . '@forgotPassword')->withoutMiddleware([CheckIfAdmin::class]); +Route::get('/{path?}', \App\Http\Controllers\LandingController::class . '@catchall')->where('path', '.*');