From: Vincent Vanwaelscappel Date: Fri, 19 Apr 2024 12:55:46 +0000 (+0200) Subject: wip #6872 @3 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=70dcb8cf50ea3db65306bafcee6ec624be12c00e;p=bastide-resah.git wip #6872 @3 --- diff --git a/app/Http/Controllers/FluidbookController.php b/app/Http/Controllers/FluidbookController.php index 6055e34..9b215a7 100644 --- a/app/Http/Controllers/FluidbookController.php +++ b/app/Http/Controllers/FluidbookController.php @@ -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() { // diff --git a/app/Http/Controllers/LandingController.php b/app/Http/Controllers/LandingController.php index 7b0c15f..c8da257 100644 --- a/app/Http/Controllers/LandingController.php +++ b/app/Http/Controllers/LandingController.php @@ -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('', '', $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(); + } + } diff --git a/config/auth.php b/config/auth.php index 8b1abfe..7ea1cd1 100644 --- a/config/auth.php +++ b/config/auth.php @@ -62,7 +62,7 @@ return [ 'providers' => [ 'users' => [ 'driver' => 'eloquent', - 'model' => App\Models\User::class, + 'model' => App\Models\Client::class, ], 'backpack' => [ diff --git a/resources/webflow/js/custom.js b/resources/webflow/js/custom.js index 3bee40e..b9ee901 100644 --- a/resources/webflow/js/custom.js +++ b/resources/webflow/js/custom.js @@ -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(''); }); diff --git a/routes/web.php b/routes/web.php index dcd368e..038f164 100644 --- a/routes/web.php +++ b/routes/web.php @@ -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]);