From 03b7f4236a2a05bc4856e59a3dc57b89ccfa3b6b Mon Sep 17 00:00:00 2001 From: Anders Date: Wed, 1 Jul 2020 10:13:49 +0200 Subject: [PATCH] Users able to change password --- .../app/Http/Controllers/UserController.php | 15 +++++++++---- .../views/app/users/account.blade.php | 1 + .../resources/views/app/users/edit.blade.php | 4 +++- .../views/app/users/editpass.blade.php | 22 +++++++++++++++++++ skolehjem/routes/web.php | 2 ++ 5 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 skolehjem/resources/views/app/users/editpass.blade.php diff --git a/skolehjem/app/Http/Controllers/UserController.php b/skolehjem/app/Http/Controllers/UserController.php index d39c252..6a0ce84 100644 --- a/skolehjem/app/Http/Controllers/UserController.php +++ b/skolehjem/app/Http/Controllers/UserController.php @@ -153,11 +153,13 @@ class UserController extends Controller /** @var User $user */ $user->update($data); - $user->roles()->detach(); - $user->forgetCachedPermissions(); + if ($request->roles != null) { + $user->roles()->detach(); + $user->forgetCachedPermissions(); - foreach ($request->roles as $role){ - $user->assignRole($role); + foreach ($request->roles as $role){ + $user->assignRole($role); + } } $user->save(); @@ -246,4 +248,9 @@ class UserController extends Controller { return Response::detect("users.edit"); } + + public function accounteditpass() + { + return Response::detect("users.editpass"); + } } diff --git a/skolehjem/resources/views/app/users/account.blade.php b/skolehjem/resources/views/app/users/account.blade.php index 1572b8f..0d6d374 100644 --- a/skolehjem/resources/views/app/users/account.blade.php +++ b/skolehjem/resources/views/app/users/account.blade.php @@ -11,5 +11,6 @@

Email: {{ Auth::user()->email }}

Telefon Nr.: {{ Auth::user()->phone }}

Rediger Oplysninger + Ændre Password @endsection diff --git a/skolehjem/resources/views/app/users/edit.blade.php b/skolehjem/resources/views/app/users/edit.blade.php index 73ee773..a43f37d 100644 --- a/skolehjem/resources/views/app/users/edit.blade.php +++ b/skolehjem/resources/views/app/users/edit.blade.php @@ -7,7 +7,9 @@ @section("content")

Konto

-
+ Auth::user()]) }}"> + @csrf + @method("put") Navn: name_last }}" disabled> Email: diff --git a/skolehjem/resources/views/app/users/editpass.blade.php b/skolehjem/resources/views/app/users/editpass.blade.php new file mode 100644 index 0000000..e04e51c --- /dev/null +++ b/skolehjem/resources/views/app/users/editpass.blade.php @@ -0,0 +1,22 @@ +@extends("app.layout.base") + +@section("title") + Account +@endsection + +@section("content") +
+

Konto

+ Auth::user()]) }}"> + @csrf + @method("put") + Nuværende Password: + + Nyt Password: + + Bekræft Nyt Password: + + + +
+@endsection diff --git a/skolehjem/routes/web.php b/skolehjem/routes/web.php index 38e1ae5..703d357 100644 --- a/skolehjem/routes/web.php +++ b/skolehjem/routes/web.php @@ -27,6 +27,8 @@ Route::get("/forgot", "UserController@showForgot")->name("users.show-forgot"); Route::post("/forgot", "UserController@forgot")->name("users.forgot"); Route::get("/account", "UserController@account")->name("users.account"); Route::get("/account/edit", "UserController@accountedit")->name("users.accountedit"); +Route::get("/account/editpass", "UserController@accounteditpass")->name("users.accounteditpass"); +Route::post("/account/update", "UserController@update")->name("users.accountupdate"); Route::get("phones", "PhoneController@index")->name("phones.index");