]> _ Git - bastide-resah.git/commitdiff
wip #6872 @3
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 19 Apr 2024 12:55:46 +0000 (14:55 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 19 Apr 2024 12:55:46 +0000 (14:55 +0200)
app/Http/Controllers/FluidbookController.php
app/Http/Controllers/LandingController.php
config/auth.php
resources/webflow/js/custom.js
routes/web.php

index 6055e34dd9d30733ee8cea618fe68796f0ce561d..9b215a7a688bfab1076a34786e679be6f44f7fdd 100644 (file)
@@ -41,6 +41,11 @@ class FluidbookController extends Controller
         }
     }
 
+    protected function auth()
+    {
+        return response((!auth()->guest()) ? '1' : '0')->header('Content-Type', 'text/plain');
+    }
+
     protected function login()
     {
 //
index 7b0c15fb8cdf9b5e54a8c2bdafd79deca0d5b35d..c8da2577f9358431e6d23ed9b5b5680eca632f6f 100644 (file)
@@ -3,6 +3,7 @@
 namespace App\Http\Controllers;
 
 use Cubist\Backpack\Http\Controllers\Base\XSendFileController;
+use Illuminate\Support\Facades\Auth;
 
 class LandingController extends Controller
 {
@@ -13,7 +14,7 @@ class LandingController extends Controller
         }
 
         $relayPath = resource_path('webflow') . '/' . $path;
-        if (str_ends_with( $path,'.html')) {
+        if (str_ends_with($path, '.html')) {
             $html = file_get_contents($relayPath);
             $html = str_replace('</head>', '<meta name="csrf-token" content="' . csrf_token() . '"/></head>', $html);
             return response($html)->header('Content-Type', 'text/html');
@@ -21,4 +22,21 @@ class LandingController extends Controller
 
         return XSendFileController::sendfile($relayPath);
     }
+
+    public function login()
+    {
+        $request = request();
+        $credentials = $request->validate([
+            'email' => ['required', 'email'],
+            'password' => ['required'],
+        ]);
+
+        if (Auth::attempt($credentials)) {
+            $request->session()->regenerate();
+            return redirect()->intended('dashboard');
+        }
+
+        return back();
+    }
+
 }
index 8b1abfe6cc67b5d4f6be42af589ca62494191eb1..7ea1cd183c0f0ec9f7050fa0860763b39ea332e2 100644 (file)
@@ -62,7 +62,7 @@ return [
     'providers' => [
         'users' => [
             'driver' => 'eloquent',
-            'model' => App\Models\User::class,
+            'model' => App\Models\Client::class,
         ],
 
         'backpack' => [
index 3bee40edd04af3089bf6a9befc2447cd653b9705..b9ee901e6c97ceec9a88ef53f08063f15425b6d8 100644 (file)
@@ -1,15 +1,5 @@
 $(function () {
-    $('#wf-form-login').on('submit', function (e) {
-        $.ajax(
-            {
-                url: $(this).attr('action'),
-                method: "POST",
-                data: $(this).serialize(),
-                dataType: 'json',
-                success: function (data) {
-
-                }
-            });
-        return false;
-    });
+    console.log($('meta[name="csrf-token"]'));
+    $('#wf-form-login').attr('action', '/landing/login');
+    $("#wf-form-login").append('<input type="hidden" name="_token" value="' + $('meta[name="csrf-token"]').attr('content') + '" />');
 });
index dcd368e25033b54a778f8c1181e29784fd3f8dd8..038f164f44d40c8791bc4376121a52783ee7401a 100644 (file)
@@ -6,11 +6,12 @@ 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::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'], '/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]);