]> _ Git - bastide-resah.git/commitdiff
wip #6872 @1.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 19 Apr 2024 15:16:40 +0000 (17:16 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 19 Apr 2024 15:16:40 +0000 (17:16 +0200)
app/Http/Controllers/FluidbookController.php
app/Http/Controllers/LandingController.php
app/Models/Client.php
config/auth.php
resources/webflow/home-logged.html [new file with mode: 0644]
routes/api.php [deleted file]
routes/channels.php [deleted file]
routes/console.php [deleted file]
routes/web.php

index 9b215a7a688bfab1076a34786e679be6f44f7fdd..d3c26dd94bee3ae05f49343485d39c79679a389a 100644 (file)
@@ -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()
index c8da2577f9358431e6d23ed9b5b5680eca632f6f..eb866ae2e46fc1e149c1b49b9088b5fde72840aa 100644 (file)
@@ -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();
+    }
+
 }
index b4b4cb00ac2d937abd7df2f7f01f3ac55ad69c13..4de358c5d37e990d30f184d69f374ec945a1f5bd 100644 (file)
@@ -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']);
index 7ea1cd183c0f0ec9f7050fa0860763b39ea332e2..09aef648cccf3d1b3c494a2c746ce0ce5f2a83bb 100644 (file)
@@ -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 (file)
index 0000000..8cf1578
--- /dev/null
@@ -0,0 +1 @@
+<a href="/catalogue/">Voir le catalogue</a>
diff --git a/routes/api.php b/routes/api.php
deleted file mode 100644 (file)
index 889937e..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-
-use Illuminate\Http\Request;
-use Illuminate\Support\Facades\Route;
-
-/*
-|--------------------------------------------------------------------------
-| API Routes
-|--------------------------------------------------------------------------
-|
-| Here is where you can register API routes for your application. These
-| routes are loaded by the RouteServiceProvider and all of them will
-| be assigned to the "api" middleware group. Make something great!
-|
-*/
-
-Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
-    return $request->user();
-});
diff --git a/routes/channels.php b/routes/channels.php
deleted file mode 100644 (file)
index 1f87c11..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php
-
-use Illuminate\Support\Facades\Broadcast;
-
-/*
-|--------------------------------------------------------------------------
-| Broadcast Channels
-|--------------------------------------------------------------------------
-|
-| Here you may register all of the event broadcasting channels that your
-| application supports. The given channel authorization callbacks are
-| used to check if an authenticated user can listen to the channel.
-|
-*/
-
-Broadcast::channel('App.Models.User.{id}', function (bastide-resah, $id) {
-    return (int) bastide-resah->id === (int) $id;
-});
diff --git a/routes/console.php b/routes/console.php
deleted file mode 100644 (file)
index e05f4c9..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-
-use Illuminate\Foundation\Inspiring;
-use Illuminate\Support\Facades\Artisan;
-
-/*
-|--------------------------------------------------------------------------
-| Console Routes
-|--------------------------------------------------------------------------
-|
-| This file is where you may define all of your Closure based console
-| commands. Each Closure is bound to a command instance allowing a
-| simple approach to interacting with each command's IO methods.
-|
-*/
-
-Artisan::command('inspire', function () {
-    $this->comment(Inspiring::quote());
-})->purpose('Display an inspiring quote');
index 038f164f44d40c8791bc4376121a52783ee7401a..90cdf49ed9b939fbb316fedeea8e105b39b4d8f1 100644 (file)
@@ -1,18 +1,19 @@
 <?php
 
-use App\Http\Middleware\CheckIfAdmin;
 use App\Http\Middleware\VerifyCsrfToken;
 use Illuminate\Support\Facades\Route;
 
+
 Route::get('/catalogue/{path?}', \App\Http\Controllers\CatalogController::class . '@index')->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', '.*');