This commit is contained in:
frederikpyt 2020-07-01 10:32:52 +02:00
commit 432d9042fd
5 changed files with 39 additions and 5 deletions

View File

@ -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");
}
}

View File

@ -11,5 +11,6 @@
<h4 class="mt-0">Email: {{ Auth::user()->email }}</h4>
<h4 class="mt-0">Telefon Nr.: {{ Auth::user()->phone }}</h4>
<a class="btn text-center btn-sde-blue mt-1" href="{{ route("users.accountedit") }}">Rediger Oplysninger</a>
<a class="btn text-center btn-sde-blue mt-1" href="{{ route("users.accounteditpass") }}">Ændre Password</a>
</main>
@endsection

View File

@ -7,7 +7,9 @@
@section("content")
<main>
<h1 class="text-center sde-blue mt-0">Konto</h1>
<form action="">
<form method="post" action="{{ route("users.update", ['user' => Auth::user()]) }}">
@csrf
@method("put")
<span>Navn:</span>
<input type="text" name="name" id="name" value="{{ Auth::user()->name_first . " " . Auth::user()->name_last }}" disabled>
<span>Email:</span>

View File

@ -0,0 +1,22 @@
@extends("app.layout.base")
@section("title")
Account
@endsection
@section("content")
<main>
<h1 class="text-center sde-blue mt-0">Konto</h1>
<form method="post" action="{{ route("users.update", ['user' => Auth::user()]) }}">
@csrf
@method("put")
<span>Nuværende Password:</span>
<input type="password" name="oldpassword" id="old" required>
<span>Nyt Password:</span>
<input type="password" name="password" id="new" required>
<span>Bekræft Nyt Password:</span>
<input type="password" name="confirmpassword" id="confirm" required>
<button type="submit" class="btn text-center btn-sde-blue mt-1">Rediger</button>
</form>
</main>
@endsection

View File

@ -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");