From 6a41536d5761729d9a52f2363ee044d237752fe1 Mon Sep 17 00:00:00 2001 From: Deon George Date: Thu, 25 Apr 2024 15:44:06 +1000 Subject: [PATCH] Enable user reseting password --- app/Http/Controllers/UserController.php | 7 ++++++- resources/views/user/addedit.blade.php | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 0562e8c..b9bd4a8 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers; use Illuminate\Auth\Events\Registered; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Validator; use App\Http\Requests\UserRequest; @@ -23,13 +24,17 @@ class UserController extends Controller if (! $o->exists) $o->password = base64_encode(random_bytes(20)); + elseif ($request->password) + $o->password = Hash::make($request->password); $o->save(); if ($o->wasRecentlyCreated) event(new Registered($o)); - return redirect()->to('user'); + return redirect() + ->to('user/addedit/'.$o->id) + ->with('success','User Updated'); } return view('user.addedit') diff --git a/resources/views/user/addedit.blade.php b/resources/views/user/addedit.blade.php index 057bb65..0b95f0a 100644 --- a/resources/views/user/addedit.blade.php +++ b/resources/views/user/addedit.blade.php @@ -11,6 +11,8 @@
+ @includeWhen(session()->has('success'),'widgets.success-row',['msg'=>session()->get('success')]) +

@if($o->exists) Update @else Add @endif User