From b5d242c846f73efa513e5b187ab7b68620991ddb Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Tue, 30 Apr 2024 15:33:02 +0200 Subject: [PATCH] wip #6888 @4 --- app/Http/Controllers/FluidbookController.php | 9 +---- app/Http/Controllers/ForgotPassword.php | 42 ++++++++++++++++++++ app/Http/Controllers/LandingController.php | 2 + app/Models/Client.php | 6 +++ app/Notifications/ResahNotification.php | 4 ++ routes/web.php | 6 ++- 6 files changed, 60 insertions(+), 9 deletions(-) create mode 100644 app/Http/Controllers/ForgotPassword.php diff --git a/app/Http/Controllers/FluidbookController.php b/app/Http/Controllers/FluidbookController.php index d11a151..adebb5e 100644 --- a/app/Http/Controllers/FluidbookController.php +++ b/app/Http/Controllers/FluidbookController.php @@ -12,6 +12,8 @@ use Illuminate\Support\Facades\Validator; class FluidbookController extends Controller { + use ForgotPassword; + protected function signin() { $validator = Validator::make(request()->all(), [ @@ -81,11 +83,6 @@ class FluidbookController extends Controller } } - protected function forgotpassword() - { - // - } - public static function loadData() { @@ -141,8 +138,6 @@ class FluidbookController extends Controller $order->total_ht = $total; $order->save(); - - $user->notify(new ResahNotification(ResahNotification::QUOTE_REQUEST_SENT, $order)); User::withoutGlobalScopes()->find(3)->notify(new ResahNotification(ResahNotification::QUOTE_REQUEST, $order)); diff --git a/app/Http/Controllers/ForgotPassword.php b/app/Http/Controllers/ForgotPassword.php new file mode 100644 index 0000000..8b7631e --- /dev/null +++ b/app/Http/Controllers/ForgotPassword.php @@ -0,0 +1,42 @@ +sendResetLink( + ['email' => request('email')], + ); + + return $status === Password::RESET_LINK_SENT + ? response()->json(['status' => __($status)], 200) + : response()->json(['status' => __($status)], 400); + } + + protected function resetPassword($email, $token) + { + + } + + protected function changePassword() + { + + } + + protected function guard() + { + return Auth::guard('clients'); + } + + protected function broker() + { + return Password::broker('clients'); + } + +} diff --git a/app/Http/Controllers/LandingController.php b/app/Http/Controllers/LandingController.php index 2efa16c..461603d 100644 --- a/app/Http/Controllers/LandingController.php +++ b/app/Http/Controllers/LandingController.php @@ -7,6 +7,8 @@ use Illuminate\Support\Facades\Auth; class LandingController extends Controller { + use ForgotPassword; + public function catchall($path = '') { if (!$path) { diff --git a/app/Models/Client.php b/app/Models/Client.php index d92e800..bb48f24 100644 --- a/app/Models/Client.php +++ b/app/Models/Client.php @@ -5,6 +5,7 @@ namespace App\Models; use App\Http\Controllers\Operations\Client\Fluidbook; use App\Http\Controllers\Operations\Client\Landing; use App\Notifications\ResahNotification; +use Backpack\CRUD\app\Notifications\ResetPasswordNotification; use Cubist\Backpack\Magic\Fields\Text; use Cubist\Backpack\Magic\Models\CubistMagicAuthenticatable; use Illuminate\Notifications\Notifiable; @@ -43,4 +44,9 @@ class Client extends CubistMagicAuthenticatable } return parent::onSaving(); } + + public function sendPasswordResetNotification($token) + { + $this->notify(new ResahNotification(ResahNotification::FORGOT_PASSWORD, ['token' => $token, 'email' => $this->email])); + } } diff --git a/app/Notifications/ResahNotification.php b/app/Notifications/ResahNotification.php index a116ce6..916f7e0 100644 --- a/app/Notifications/ResahNotification.php +++ b/app/Notifications/ResahNotification.php @@ -70,6 +70,10 @@ class ResahNotification extends Notification $subject = 'Votre demande de devis sur Bastide-resah.fr'; $html = 'Votre demande de devis est en cours de traitement (récapitulatif en pièce jointe).
Nous vous recontacterons dans les meilleurs délais.'; //$file = storage_path('orders/' . $this->data->id . '.pdf'); + } else if ($this->type === self::FORGOT_PASSWORD) { + $url = url('/landing/resetpassword/' . $this->data['email'] . '/' . $this->data['token']); + $subject = 'Réinitialisation de votre mot de passe'; + $html = 'Vous recevez cet e-mail car nous avons reçu une demande de réinitialisation de mot de passe pour votre compte. Cliquez sur le lien suivant pour le réinitialiser : ' . $url . '


Si vous n\'êtes pas à l\'origine de cette demande, vous pouvez simplement ignorer cet e-mail.'; } diff --git a/routes/web.php b/routes/web.php index 4f991a9..a278fdf 100644 --- a/routes/web.php +++ b/routes/web.php @@ -9,13 +9,15 @@ Route::get('/catalogue_invite/{path?}', \App\Http\Controllers\CatalogController: 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(['post','get'], '/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'], '/fluidbook/order', \App\Http\Controllers\FluidbookController::class . '@order')->withoutMiddleware([VerifyCsrfToken::class]); 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','get'], '/landing/forgotpassword', \App\Http\Controllers\LandingController::class . '@forgotPassword'); Route::match(['get'], '/landing/logout', \App\Http\Controllers\LandingController::class . '@logout'); +Route::match(['get'], '/landing/resetpassword/{email}/{token}', \App\Http\Controllers\LandingController::class . '@resetPassword'); +Route::match(['post'], '/landing/resetpassword', \App\Http\Controllers\LandingController::class . '@changePassword'); Route::get('/{path?}', \App\Http\Controllers\LandingController::class . '@catchall')->where('path', '.*'); -- 2.39.5