From d8ff713b90adbf33ebc20c3194819578c8e9ce99 Mon Sep 17 00:00:00 2001
From: Anders <anders164a@gmail.com>
Date: Fri, 31 Jul 2020 10:38:10 +0200
Subject: [PATCH 01/10] Added "see password" button in admin - With CSS &
 Script (Script in file) - Edited form style and input styles

---
 skolehjem/public/css/webapp.css               |  2 +-
 .../views/admin/users/edit.blade.php          | 40 +++++++++++++++++--
 .../views/app/users/editpass.blade.php        | 19 +++++----
 3 files changed, 49 insertions(+), 12 deletions(-)

diff --git a/skolehjem/public/css/webapp.css b/skolehjem/public/css/webapp.css
index 9c36886..6744834 100644
--- a/skolehjem/public/css/webapp.css
+++ b/skolehjem/public/css/webapp.css
@@ -6943,7 +6943,7 @@ main {
   display: inline-block;
 }
 
-.spaneye {
+.fa-eye {
     position: absolute;
     font-size: 25px;
     color: grey;
diff --git a/skolehjem/resources/views/admin/users/edit.blade.php b/skolehjem/resources/views/admin/users/edit.blade.php
index 4fc653d..078b106 100644
--- a/skolehjem/resources/views/admin/users/edit.blade.php
+++ b/skolehjem/resources/views/admin/users/edit.blade.php
@@ -11,7 +11,7 @@
 
 @section("content")
     <h1>Rediger Bruger:</h1>
-    <form method="post" action="{{ route("users.update", ['user' => $user]) }}">
+    <form method="post" action="{{ route("users.update", ['user' => $user]) }}" style="display: inline-table;">
         @csrf
         @method("put")
         <label for="name_first">Fornavn:</label>
@@ -21,13 +21,15 @@
         <label for="email">Email:</label>
             <input type="email" name="email" id="email" value="{{ $user->email }}" required>
         <label for="password1">Password: (Forblives blank, hvis password ikke skal ændres)</label>
-            <input type="password" name="password" id="password1" value="">
+            <input type="password" name="password" id="password1" value="" placeholder="******">
+            <span toggle="#password-field" class="fa fa-fw fa-eye field-icon toggle-password" id="fa-new" onclick="show('password1', 'fa-new')"></span>
         <label for="password2">Confirm Password: (Forblives blank, hvis password ikke skal ændres)</label>
-            <input type="password" id="password2" value="">
+            <input type="password" id="password2" value="" placeholder="******">
+        <span toggle="#password-field" class="fa fa-fw fa-eye field-icon toggle-password" id="fa-confirm" onclick="show('password2', 'fa-confirm')"></span>
         <label for="tel">Telefon nr:</label>
             <input type="tel" name="phone" id="tel" value="{{ $user->phone }}" required>
         <label for="role">Rolle: (Brug ctrl og shift til at vælge flere)</label>
-        <select name="roles[]" id="roles" class="mb-2" multiple="multiple" required>
+        <select class="w-100" name="roles[]" id="roles" class="mb-2" multiple="multiple" required>
                 @if(count($user->roles) == 0)
                     <option disabled selected> -- Vælg Rolle(r) -- </option>
                     <option value>Ingen Rolle</option>
@@ -51,4 +53,34 @@
             </select>
         <input type="submit" class="btn btn-dark text-white" value="Rediger">
     </form>
+    <style>
+        input {
+            width: calc(100% - 8px);
+        }
+
+        .fa-eye {
+            position: absolute;
+            font-size: 25px;
+            color: grey;
+            margin: 7.5px 0 0 -45px;
+        }
+
+    </style>
+@endsection
+
+@section("scripts")
+    <script>
+        function show($passID, $faID) {
+            var inputPass = document.getElementById($passID);
+            var faEye = document.getElementById($faID);
+
+            if (inputPass.type === "password") {
+                inputPass.type = "text";
+                faEye.style.color = "#000";
+            } else {
+                inputPass.type = "password";
+                faEye.style.color = "#808080";
+            }
+        }
+    </script>
 @endsection
diff --git a/skolehjem/resources/views/app/users/editpass.blade.php b/skolehjem/resources/views/app/users/editpass.blade.php
index b1da050..e5ef10c 100644
--- a/skolehjem/resources/views/app/users/editpass.blade.php
+++ b/skolehjem/resources/views/app/users/editpass.blade.php
@@ -7,23 +7,28 @@
 @section("content")
     <main>
         <h1 class="text-center sde-blue mt-0">Konto</h1>
-        <form method="post" action="{{ route("users.update", ['user' => Auth::user()]) }}" style="display: block;">
+        <form method="post" action="{{ route("users.update", ['user' => Auth::user()]) }}" style="display: inline-table;">
             @csrf
             @method("put")
             <span>Nuværende Password:</span>
-            <input type="password" name="oldpassword" id="old" placeholder="******" required style="width: calc(100% - 12px)">
-            <span toggle="#password-field" class="fa fa-fw fa-eye field-icon toggle-password spaneye" id="fa-old" onclick="show('old', 'fa-old')"></span>
+            <input type="password" name="oldpassword" id="old" placeholder="******">
+            <span toggle="#password-field" class="fa fa-fw fa-eye field-icon toggle-password" id="fa-old" onclick="show('old', 'fa-old')"></span>
             <span>Nyt Password:</span>
-            <input class="w-100" type="password" name="password" id="new" placeholder="******" required style="width: calc(100% - 12px)">
-            <span toggle="#password-field" class="fa fa-fw fa-eye field-icon toggle-password spaneye" id="fa-new" onclick="show('new', 'fa-new')"></span>
+            <input class="w-100" type="password" name="password" id="new" placeholder="******" required style="width: calc(100% - 8px)">
+            <span toggle="#password-field" class="fa fa-fw fa-eye field-icon toggle-password" id="fa-new" onclick="show('new', 'fa-new')"></span>
             <span>Bekræft Nyt Password:</span>
-            <input class="w-100" type="password" name="confirmpassword" id="confirm" placeholder="******" required style="width: calc(100% - 12px)">
-            <span toggle="#password-field" class="fa fa-fw fa-eye field-icon toggle-password spaneye" id="fa-confirm" onclick="show('confirm', 'fa-confirm')"></span>
+            <input class="w-100" type="password" name="confirmpassword" id="confirm" placeholder="******" required style="width: calc(100% - 8px)">
+            <span toggle="#password-field" class="fa fa-fw fa-eye field-icon toggle-password" id="fa-confirm" onclick="show('confirm', 'fa-confirm')"></span>
             {!! session()->get('error#notsamepass') !!}
             {!! session()->get('error#oldpass') !!}
             <button type="submit" class="btn text-center btn-sde-blue mt-1">Rediger</button>
         </form>
     </main>
+    <style>
+        input {
+            width: calc(100% - 8px);
+        }
+    </style>
 @endsection
 
 @section("scripts")

From 1f5660001e95ca09836b6a7ff021d1131a7dface Mon Sep 17 00:00:00 2001
From: Anders <anders164a@gmail.com>
Date: Fri, 31 Jul 2020 11:14:24 +0200
Subject: [PATCH 02/10] Fixed - Being able to change credentials without
 removing password Added - Checking if the password is the same to confirm
 password in admin

---
 .../app/Http/Controllers/UserController.php   | 22 ++++++++++++++-----
 .../views/admin/users/edit.blade.php          |  3 ++-
 .../views/app/users/editpass.blade.php        |  6 ++---
 3 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/skolehjem/app/Http/Controllers/UserController.php b/skolehjem/app/Http/Controllers/UserController.php
index 3abe711..d068c33 100644
--- a/skolehjem/app/Http/Controllers/UserController.php
+++ b/skolehjem/app/Http/Controllers/UserController.php
@@ -121,14 +121,24 @@ class UserController extends Controller
      */
     public function update(Request $request, $id)
     {
-        $data = $request->all();
-
         $user = User::find($id);
 
         if($id === Auth::id() || auth()->user()->hasPermissionTo("user.edit")) {
             if ($request->roles != null) { //You can only edit roles on the admin site, so if there is an input roles, then update user info and edit roles
-                /** @var User $user */
-                $user->update($data);
+                if ($request->password != "") { // If you have edited the password, then run this
+                    if ($request->password == $request->password2) { // If the password is the same as confirm password, then update everything from user
+                        $data = $request->all();
+                        /** @var User $user */
+                        $user->update($data);
+                    } else // Else go back with an error message
+                        return redirect()->route("users.edit", ['user' => $id])->with('error#passnotsame', '<p>Der stod ikke det samme i `Password` & `Confirm Password`!</p>');
+                }
+                else { // If you haven't touched the password, then update everything else but password
+                    $data = $request->only(['name_first', 'name_last', 'email', 'phone', 'roles']);
+                    /** @var User $user */
+                    $user->update($data);
+                }
+
                 $user->roles()->detach();
                 $user->forgetCachedPermissions();
 
@@ -138,6 +148,7 @@ class UserController extends Controller
 
                 //$user->save();
             } else { // Else if you're not on the admin site (user site)
+                $data = $request->all();
                 if ($request->input('password') != null) { // If you're editing the password
                     if ($request->input('password') != $request->input('confirmpassword')) { // If new password and new password confirm is not the same, go back with fail message.
                         return redirect()->route("users.accounteditpass")->with('error#notsamepass', '<p class="text-center">Der stod ikke det samme i `Nyt Password` & `Bekræft Nyt Password`!</p>');
@@ -148,9 +159,10 @@ class UserController extends Controller
                         $user->update($data);
                         Auth::logout();
 
-                        return redirect()->route("users.login")->with('success#passwordchange', '<p class="text-center">Dit password er hermed ændret!</p>');
+                        return redirect()->route("users.login")->with('success#passwordchange', '<p class="text-center text-white">Dit password er hermed ændret!</p>');
                     }
                 } else { // Else if you're not editing the password but anything else (Email, Phone Number). Then update user.
+                    $data = $request->all();
                     $user->update($data);
 
                     return redirect()->route("users.account")->with('success#credentialschanged', '<p class="text-center">Dine oplysninger er hermed ændret!</p>');
diff --git a/skolehjem/resources/views/admin/users/edit.blade.php b/skolehjem/resources/views/admin/users/edit.blade.php
index 078b106..b3feb3a 100644
--- a/skolehjem/resources/views/admin/users/edit.blade.php
+++ b/skolehjem/resources/views/admin/users/edit.blade.php
@@ -11,6 +11,7 @@
 
 @section("content")
     <h1>Rediger Bruger:</h1>
+    {!! session()->get('error#passnotsame') !!}
     <form method="post" action="{{ route("users.update", ['user' => $user]) }}" style="display: inline-table;">
         @csrf
         @method("put")
@@ -24,7 +25,7 @@
             <input type="password" name="password" id="password1" value="" placeholder="******">
             <span toggle="#password-field" class="fa fa-fw fa-eye field-icon toggle-password" id="fa-new" onclick="show('password1', 'fa-new')"></span>
         <label for="password2">Confirm Password: (Forblives blank, hvis password ikke skal ændres)</label>
-            <input type="password" id="password2" value="" placeholder="******">
+            <input type="password" name="password2" id="password2" value="" placeholder="******">
         <span toggle="#password-field" class="fa fa-fw fa-eye field-icon toggle-password" id="fa-confirm" onclick="show('password2', 'fa-confirm')"></span>
         <label for="tel">Telefon nr:</label>
             <input type="tel" name="phone" id="tel" value="{{ $user->phone }}" required>
diff --git a/skolehjem/resources/views/app/users/editpass.blade.php b/skolehjem/resources/views/app/users/editpass.blade.php
index e5ef10c..43b0654 100644
--- a/skolehjem/resources/views/app/users/editpass.blade.php
+++ b/skolehjem/resources/views/app/users/editpass.blade.php
@@ -12,13 +12,13 @@
             @method("put")
             <span>Nuværende Password:</span>
             <input type="password" name="oldpassword" id="old" placeholder="******">
-            <span toggle="#password-field" class="fa fa-fw fa-eye field-icon toggle-password" id="fa-old" onclick="show('old', 'fa-old')"></span>
+            <span class="fa fa-fw fa-eye field-icon toggle-password" id="fa-old" onclick="show('old', 'fa-old')"></span>
             <span>Nyt Password:</span>
             <input class="w-100" type="password" name="password" id="new" placeholder="******" required style="width: calc(100% - 8px)">
-            <span toggle="#password-field" class="fa fa-fw fa-eye field-icon toggle-password" id="fa-new" onclick="show('new', 'fa-new')"></span>
+            <span class="fa fa-fw fa-eye field-icon toggle-password" id="fa-new" onclick="show('new', 'fa-new')"></span>
             <span>Bekræft Nyt Password:</span>
             <input class="w-100" type="password" name="confirmpassword" id="confirm" placeholder="******" required style="width: calc(100% - 8px)">
-            <span toggle="#password-field" class="fa fa-fw fa-eye field-icon toggle-password" id="fa-confirm" onclick="show('confirm', 'fa-confirm')"></span>
+            <span class="fa fa-fw fa-eye field-icon toggle-password" id="fa-confirm" onclick="show('confirm', 'fa-confirm')"></span>
             {!! session()->get('error#notsamepass') !!}
             {!! session()->get('error#oldpass') !!}
             <button type="submit" class="btn text-center btn-sde-blue mt-1">Rediger</button>

From 27fd564e9f3ef0a90ccaf81b8888a83f883eb10f Mon Sep 17 00:00:00 2001
From: frederikpyt <frederikpyt@gmail.com>
Date: Mon, 3 Aug 2020 08:33:11 +0200
Subject: [PATCH 03/10] Fixed permissions, seeders and security

---
 skolehjem/app/Http/Controllers/UserController.php | 10 ++++++----
 skolehjem/database/seeds/PermissionSeeder.php     |  1 +
 skolehjem/database/seeds/RoleSeeder.php           |  1 +
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/skolehjem/app/Http/Controllers/UserController.php b/skolehjem/app/Http/Controllers/UserController.php
index d068c33..163dd8b 100644
--- a/skolehjem/app/Http/Controllers/UserController.php
+++ b/skolehjem/app/Http/Controllers/UserController.php
@@ -18,7 +18,7 @@ class UserController extends Controller
 {
     public function __construct()
     {
-        $this->middleware([ "auth" ])->only(["logout", "accountedit", "accounteditpass"]);
+        $this->middleware([ "auth" ])->only(["logout"]);
         $this->middleware([ "guest" ])->only("login");
 
         $this->middleware([ "check.auth:user.list" ])->only("index");
@@ -26,6 +26,8 @@ class UserController extends Controller
         $this->middleware([ "check.auth:user.create" ])->only("create");
         $this->middleware([ "check.auth:user.edit" ])->only("edit", "update");
         $this->middleware([ "check.auth:user.delete" ])->only("delete");
+
+        $this->middleware([ "check.auth:ownuser.edit" ])->only("update", "accountedit", "accounteditpass");
     }
 
     /**
@@ -124,7 +126,7 @@ class UserController extends Controller
         $user = User::find($id);
 
         if($id === Auth::id() || auth()->user()->hasPermissionTo("user.edit")) {
-            if ($request->roles != null) { //You can only edit roles on the admin site, so if there is an input roles, then update user info and edit roles
+            if ($request->roles != null && auth()->user()->hasPermissionTo("user.edit")) { //You can only edit roles on the admin site, so if there is an input roles, then update user info and edit roles
                 if ($request->password != "") { // If you have edited the password, then run this
                     if ($request->password == $request->password2) { // If the password is the same as confirm password, then update everything from user
                         $data = $request->all();
@@ -148,8 +150,8 @@ class UserController extends Controller
 
                 //$user->save();
             } else { // Else if you're not on the admin site (user site)
-                $data = $request->all();
                 if ($request->input('password') != null) { // If you're editing the password
+                    $data = $request->only(['name_first', 'name_last', 'email', 'phone', 'password']);
                     if ($request->input('password') != $request->input('confirmpassword')) { // If new password and new password confirm is not the same, go back with fail message.
                         return redirect()->route("users.accounteditpass")->with('error#notsamepass', '<p class="text-center">Der stod ikke det samme i `Nyt Password` & `Bekræft Nyt Password`!</p>');
                     } elseif (!Hash::check($request->input('oldpassword'), $user->password)) { // If the written current password and current password in DB is not the same, go back with fail message.
@@ -162,7 +164,7 @@ class UserController extends Controller
                         return redirect()->route("users.login")->with('success#passwordchange', '<p class="text-center text-white">Dit password er hermed ændret!</p>');
                     }
                 } else { // Else if you're not editing the password but anything else (Email, Phone Number). Then update user.
-                    $data = $request->all();
+                    $data = $request->only(['name_first', 'name_last', 'email', 'phone']);
                     $user->update($data);
 
                     return redirect()->route("users.account")->with('success#credentialschanged', '<p class="text-center">Dine oplysninger er hermed ændret!</p>');
diff --git a/skolehjem/database/seeds/PermissionSeeder.php b/skolehjem/database/seeds/PermissionSeeder.php
index 4c6c995..fb01e2a 100644
--- a/skolehjem/database/seeds/PermissionSeeder.php
+++ b/skolehjem/database/seeds/PermissionSeeder.php
@@ -22,6 +22,7 @@ class PermissionSeeder extends Seeder
             "user.show" => "Shows another user profile.",
             "user.edit" => "Allows editing of other users.",
             "user.delete" => "Allows deleting of other users.",
+            "ownuser.edit" => "Allows editing of your own user",
 
             /**
              * The CALENDAR specific permissions
diff --git a/skolehjem/database/seeds/RoleSeeder.php b/skolehjem/database/seeds/RoleSeeder.php
index 4d90468..f369303 100644
--- a/skolehjem/database/seeds/RoleSeeder.php
+++ b/skolehjem/database/seeds/RoleSeeder.php
@@ -48,6 +48,7 @@ class RoleSeeder extends Seeder
         $brugerPermissions->add(\Spatie\Permission\Models\Permission::query()->where("name", "=", "washing.machine.reservation.create")->first());
         $brugerPermissions->add(\Spatie\Permission\Models\Permission::query()->where("name", "=", "washing.machine.reservation.delete")->first());
         $brugerPermissions->add(\Spatie\Permission\Models\Permission::query()->where("name", "=", "washing.machine.reservation.list")->first());
+        $brugerPermissions->add(\Spatie\Permission\Models\Permission::query()->where("name", "=", "ownuser.edit")->first());
 
         //Give permissions to Bruger (id: 2)
         foreach ($brugerPermissions as $permission) {

From f14dc22d9208e37e2e586990b9c05831db1eabac Mon Sep 17 00:00:00 2001
From: frederikpyt <frederikpyt@gmail.com>
Date: Mon, 3 Aug 2020 08:35:20 +0200
Subject: [PATCH 04/10] Fixed permissions, seeders and security

---
 skolehjem/app/Http/Controllers/UserController.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/skolehjem/app/Http/Controllers/UserController.php b/skolehjem/app/Http/Controllers/UserController.php
index 163dd8b..83c285b 100644
--- a/skolehjem/app/Http/Controllers/UserController.php
+++ b/skolehjem/app/Http/Controllers/UserController.php
@@ -27,7 +27,7 @@ class UserController extends Controller
         $this->middleware([ "check.auth:user.edit" ])->only("edit", "update");
         $this->middleware([ "check.auth:user.delete" ])->only("delete");
 
-        $this->middleware([ "check.auth:ownuser.edit" ])->only("update", "accountedit", "accounteditpass");
+        $this->middleware([ "check.auth:ownuser.edit" ])->only("update", "accountedit", "accounteditpass", "account");
     }
 
     /**

From 073938a4692f6d4cfb544a965feef9cdedbf6656 Mon Sep 17 00:00:00 2001
From: frederikpyt <frederikpyt@gmail.com>
Date: Mon, 3 Aug 2020 08:45:45 +0200
Subject: [PATCH 05/10] Fixed css

---
 skolehjem/public/css/admin.css                 |  7 +++++++
 skolehjem/public/css/webapp.css                | 15 +++++++++++++++
 skolehjem/resources/sass/app/forms/_forms.scss |  7 +++++++
 skolehjem/resources/sass/webapp/_default.scss  |  8 ++++++++
 4 files changed, 37 insertions(+)

diff --git a/skolehjem/public/css/admin.css b/skolehjem/public/css/admin.css
index a07022c..600a28a 100644
--- a/skolehjem/public/css/admin.css
+++ b/skolehjem/public/css/admin.css
@@ -26,6 +26,13 @@ form {
   justify-content: center;
 }
 
+.fa-eye {
+  position: absolute;
+  font-size: 25px;
+  color: grey;
+  margin: 7.5px 0 0 -45px;
+}
+
 .btn {
   border: 0;
   border-radius: 4px;
diff --git a/skolehjem/public/css/webapp.css b/skolehjem/public/css/webapp.css
index 6744834..cd05063 100644
--- a/skolehjem/public/css/webapp.css
+++ b/skolehjem/public/css/webapp.css
@@ -26,6 +26,13 @@ form {
   justify-content: center;
 }
 
+.fa-eye {
+  position: absolute;
+  font-size: 25px;
+  color: grey;
+  margin: 7.5px 0 0 -45px;
+}
+
 .btn {
   border: 0;
   border-radius: 4px;
@@ -6633,6 +6640,14 @@ main {
   p {
     font-size: 4vw;
   }
+
+  .links {
+    position: absolute;
+    width: calc(100% - 40px);
+    bottom: 8px;
+    height: 2rem;
+    justify-content: center;
+  }
 }
 
 .mock-up-link {
diff --git a/skolehjem/resources/sass/app/forms/_forms.scss b/skolehjem/resources/sass/app/forms/_forms.scss
index 15a1e8b..2eaf11a 100644
--- a/skolehjem/resources/sass/app/forms/_forms.scss
+++ b/skolehjem/resources/sass/app/forms/_forms.scss
@@ -6,6 +6,13 @@ form {
     justify-content: center;
 }
 
+.fa-eye {
+    position: absolute;
+    font-size: 25px;
+    color: grey;
+    margin: 7.5px 0 0 -45px;
+}
+
 .btn {
     border: 0;
     border-radius: 4px;
diff --git a/skolehjem/resources/sass/webapp/_default.scss b/skolehjem/resources/sass/webapp/_default.scss
index ad64af2..0d23f7f 100644
--- a/skolehjem/resources/sass/webapp/_default.scss
+++ b/skolehjem/resources/sass/webapp/_default.scss
@@ -66,6 +66,14 @@ and (max-width : 900px)
     p {
         font-size: 4vw;
     }
+
+    .links {
+        position: absolute;
+        width: calc(100% - 40px);
+        bottom: 8px;
+        height: 2rem;
+        justify-content: center;
+    }
 }
 
 

From 1d638791178fbc6868ed9cfd4b1b515d5e09bb18 Mon Sep 17 00:00:00 2001
From: Anders <anders164a@gmail.com>
Date: Mon, 3 Aug 2020 08:46:38 +0200
Subject: [PATCH 06/10] Added "orderBy" function to event and feedback.

---
 skolehjem/app/Http/Controllers/EventController.php    | 2 +-
 skolehjem/app/Http/Controllers/FeedbackController.php | 4 ++--
 skolehjem/public/css/webapp.css                       | 6 ------
 3 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/skolehjem/app/Http/Controllers/EventController.php b/skolehjem/app/Http/Controllers/EventController.php
index 656c4cb..199fa94 100644
--- a/skolehjem/app/Http/Controllers/EventController.php
+++ b/skolehjem/app/Http/Controllers/EventController.php
@@ -31,7 +31,7 @@ class EventController extends Controller
     public function index(Request $request)
     {
 
-        $events = Event::query()->paginate($request->input("limit", 20));
+        $events = Event::query()->orderBY('date' , 'asc')->paginate($request->input("limit", 20));
 
         //returns the function with events index page and a parameter of events.
         //also Response::detect checks screen size to determine if user is on a computer or mobile.
diff --git a/skolehjem/app/Http/Controllers/FeedbackController.php b/skolehjem/app/Http/Controllers/FeedbackController.php
index 18c274b..6f8ce82 100644
--- a/skolehjem/app/Http/Controllers/FeedbackController.php
+++ b/skolehjem/app/Http/Controllers/FeedbackController.php
@@ -28,7 +28,7 @@ class FeedbackController extends Controller
      */
     public function index(Request $request)
     {
-        $feedback = Feedbacks::query()->paginate($request->input("limit", 20));
+        $feedback = Feedbacks::query()->orderBy('created_at', 'desc')->paginate($request->input("limit", 20));
 
         return Response::detect("feedbacks.index", [ "feedback" => $feedback ]);
     }
@@ -59,7 +59,7 @@ class FeedbackController extends Controller
         $feedbacks = new Feedbacks($requestBody);
         $feedbacks->save();
 
-        return Response::detect("root.index");
+        return redirect()->route("root.index");
     }
 
     /**
diff --git a/skolehjem/public/css/webapp.css b/skolehjem/public/css/webapp.css
index 6744834..441aba7 100644
--- a/skolehjem/public/css/webapp.css
+++ b/skolehjem/public/css/webapp.css
@@ -6943,9 +6943,3 @@ main {
   display: inline-block;
 }
 
-.fa-eye {
-    position: absolute;
-    font-size: 25px;
-    color: grey;
-    margin: 7.5px 0 0 -45px;
-}

From b0b2a7b4f041adfc6ff6803fdfa8c8ee4ad61e6b Mon Sep 17 00:00:00 2001
From: frederikpyt <frederikpyt@gmail.com>
Date: Mon, 3 Aug 2020 09:09:46 +0200
Subject: [PATCH 07/10] Fixed css

---
 skolehjem/public/css/webapp.css | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/skolehjem/public/css/webapp.css b/skolehjem/public/css/webapp.css
index cd05063..74ff2cf 100644
--- a/skolehjem/public/css/webapp.css
+++ b/skolehjem/public/css/webapp.css
@@ -6958,9 +6958,3 @@ main {
   display: inline-block;
 }
 
-.fa-eye {
-    position: absolute;
-    font-size: 25px;
-    color: grey;
-    margin: 7.5px 0 0 -45px;
-}

From 09fa8ce007da0a614ff51ffd2c456b98384e2a9d Mon Sep 17 00:00:00 2001
From: frederikpyt <frederikpyt@gmail.com>
Date: Mon, 3 Aug 2020 09:39:32 +0200
Subject: [PATCH 08/10] Fixed permissions

---
 .../app/Http/Controllers/UserController.php   | 46 ++++++++++++++++---
 .../resources/views/app/users/edit.blade.php  |  2 +-
 .../views/app/users/editpass.blade.php        |  2 +-
 skolehjem/routes/web.php                      | 10 ++--
 4 files changed, 46 insertions(+), 14 deletions(-)

diff --git a/skolehjem/app/Http/Controllers/UserController.php b/skolehjem/app/Http/Controllers/UserController.php
index 83c285b..7dd52d5 100644
--- a/skolehjem/app/Http/Controllers/UserController.php
+++ b/skolehjem/app/Http/Controllers/UserController.php
@@ -18,16 +18,16 @@ class UserController extends Controller
 {
     public function __construct()
     {
-        $this->middleware([ "auth" ])->only(["logout"]);
+        $this->middleware([ "auth" ])->only("logout");
         $this->middleware([ "guest" ])->only("login");
 
         $this->middleware([ "check.auth:user.list" ])->only("index");
         $this->middleware([ "check.auth:user.show" ])->only("show");
         $this->middleware([ "check.auth:user.create" ])->only("create");
-        $this->middleware([ "check.auth:user.edit" ])->only("edit", "update");
+        $this->middleware([ "check.auth:user.edit" ])->only(["edit", "update"]);
         $this->middleware([ "check.auth:user.delete" ])->only("delete");
 
-        $this->middleware([ "check.auth:ownuser.edit" ])->only("update", "accountedit", "accounteditpass", "account");
+        $this->middleware([ "check.auth:ownuser.edit" ])->only(["accountupdate", "accountedit", "accounteditpass", "account"]);
     }
 
     /**
@@ -123,6 +123,7 @@ class UserController extends Controller
      */
     public function update(Request $request, $id)
     {
+        return redirect()->route("users.account");
         $user = User::find($id);
 
         if($id === Auth::id() || auth()->user()->hasPermissionTo("user.edit")) {
@@ -147,8 +148,6 @@ class UserController extends Controller
                 foreach ($request->roles as $role) {
                     $user->assignRole($role);
                 }
-
-                //$user->save();
             } else { // Else if you're not on the admin site (user site)
                 if ($request->input('password') != null) { // If you're editing the password
                     $data = $request->only(['name_first', 'name_last', 'email', 'phone', 'password']);
@@ -164,7 +163,7 @@ class UserController extends Controller
                         return redirect()->route("users.login")->with('success#passwordchange', '<p class="text-center text-white">Dit password er hermed ændret!</p>');
                     }
                 } else { // Else if you're not editing the password but anything else (Email, Phone Number). Then update user.
-                    $data = $request->only(['name_first', 'name_last', 'email', 'phone']);
+                    $data = $request->only(['email', 'phone']);
                     $user->update($data);
 
                     return redirect()->route("users.account")->with('success#credentialschanged', '<p class="text-center">Dine oplysninger er hermed ændret!</p>');
@@ -262,6 +261,41 @@ class UserController extends Controller
         return Response::detect("users.editpass");
     }
 
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
+     */
+    public function accountupdate(Request $request)
+    {
+        $user = User::find(Auth::id());
+
+        if ($request->input('password') != null) { // If you're editing the password
+            $data = $request->only(['name_first', 'name_last', 'email', 'phone', 'password']);
+            if ($request->input('password') != $request->input('confirmpassword')) { // If new password and new password confirm is not the same, go back with fail message.
+                return redirect()->route("users.accounteditpass")->with('error#notsamepass', '<p class="text-center">Der stod ikke det samme i `Nyt Password` & `Bekræft Nyt Password`!</p>');
+            } elseif (!Hash::check($request->input('oldpassword'), $user->password)) { // If the written current password and current password in DB is not the same, go back with fail message.
+                return redirect()->route("users.accounteditpass")->with('error#oldpass', '<p class="text-center">Det indtastede password i `Nuværende Password` er ikke dit nuværende password!</p>');
+            } else { // If new password and current password is the same AND current written and current DB password is the same. Then update and logout.
+                /** @var User $user */
+                $user->update($data);
+                Auth::logout();
+
+                return redirect()->route("users.login")->with('success#passwordchange', '<p class="text-center text-white">Dit password er hermed ændret!</p>');
+            }
+        } else { // Else if you're not editing the password but anything else (Email, Phone Number). Then update user.
+            $data = $request->only(['email', 'phone']);
+            $user->update($data);
+
+            return redirect()->route("users.account")->with('success#credentialschanged', '<p class="text-center">Dine oplysninger er hermed ændret!</p>');
+        }
+        $users = User::query()->paginate(20);
+
+        return Response::detect("users.index", [
+            "users" => $users
+        ]);
+    }
 
     public function search(Request $request){
         if($request->ajax()){
diff --git a/skolehjem/resources/views/app/users/edit.blade.php b/skolehjem/resources/views/app/users/edit.blade.php
index 17f6a1f..6cdbf83 100644
--- a/skolehjem/resources/views/app/users/edit.blade.php
+++ b/skolehjem/resources/views/app/users/edit.blade.php
@@ -7,7 +7,7 @@
 @section("content")
     <main>
         <h1 class="text-center sde-blue mt-0">Konto</h1>
-    <form method="post" action="{{ route("users.update", ['user' => Auth::user()]) }}">
+    <form method="post" action="{{ route("users.accountupdate", ['user' => Auth::user()]) }}">
             @csrf
             @method("put")
             <span>Navn:</span>
diff --git a/skolehjem/resources/views/app/users/editpass.blade.php b/skolehjem/resources/views/app/users/editpass.blade.php
index 43b0654..8e38180 100644
--- a/skolehjem/resources/views/app/users/editpass.blade.php
+++ b/skolehjem/resources/views/app/users/editpass.blade.php
@@ -7,7 +7,7 @@
 @section("content")
     <main>
         <h1 class="text-center sde-blue mt-0">Konto</h1>
-        <form method="post" action="{{ route("users.update", ['user' => Auth::user()]) }}" style="display: inline-table;">
+        <form method="post" action="{{ route("users.accountupdate", ['user' => Auth::user()]) }}" style="display: inline-table;">
             @csrf
             @method("put")
             <span>Nuværende Password:</span>
diff --git a/skolehjem/routes/web.php b/skolehjem/routes/web.php
index 74380a5..6d0d6b7 100644
--- a/skolehjem/routes/web.php
+++ b/skolehjem/routes/web.php
@@ -13,10 +13,6 @@ use Illuminate\Support\Facades\Route;
 |
 */
 
-//Route::get('/', function () {
-//    return view('welcome');
-//});
-
 Route::get("/", "RootController@index")->name("root.index");
 Route::get("/home", "RootController@index")->name("root.index");
 
@@ -28,16 +24,18 @@ 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::put("/account/update", "UserController@accountupdate")->name("users.accountupdate");
 Route::get("/events/signups", "EventController@signups")->name("events.signups");
 Route::get("phones", "PhoneController@index")->name("phones.index");
+Route::get("/washing-reservationsapi", "WashingReservationController@api")->name("washing-reservations.api");
+
 Route::get("/contactsapi", "ContactController@search")->name("contacts.search");
 Route::get("/eventsapi", "EventController@search")->name("events.search");
 Route::get("/menuplansapi", "MenuPlanController@search")->name("menu-plans.search");
 Route::get("/rolesapi", "RolesController@search")->name("roles.search");
 Route::get("/userapi", "UserController@search")->name("users.search");
 Route::get("/vaskeapi", "WashingReservationController@search")->name("washing-reservations.search");
-Route::get("/washing-reservationsapi", "WashingReservationController@api")->name("washing-reservations.api");
+
 
 
 

From f2895a00e39d8233810080b92404f744c990209d Mon Sep 17 00:00:00 2001
From: Anders <anders164a@gmail.com>
Date: Mon, 3 Aug 2020 09:42:17 +0200
Subject: [PATCH 09/10] Started working on a better see password button

---
 skolehjem/public/css/admin.css                | 19 ++++++++++++++
 skolehjem/public/css/webapp.css               | 19 ++++++++++++++
 .../resources/sass/app/forms/_forms.scss      | 22 ++++++++++++++++
 .../views/app/users/editpass.blade.php        | 26 ++++++++++++++-----
 4 files changed, 79 insertions(+), 7 deletions(-)

diff --git a/skolehjem/public/css/admin.css b/skolehjem/public/css/admin.css
index 600a28a..4303884 100644
--- a/skolehjem/public/css/admin.css
+++ b/skolehjem/public/css/admin.css
@@ -31,6 +31,8 @@ form {
   font-size: 25px;
   color: grey;
   margin: 7.5px 0 0 -45px;
+  align-self: center;
+  z-index: 98;
 }
 
 .btn {
@@ -104,6 +106,23 @@ input.appinput {
   color: white;
 }
 
+.form-control {
+  flex: 1 1 auto;
+  width: 1%;
+}
+
+.input-group {
+  position: relative;
+  display: flex;
+  flex-wrap: wrap;
+  align-items: stretch;
+  width: 100%;
+}
+
+.input-group-append {
+  display: flex;
+}
+
 .d-flex {
   display: flex;
 }
diff --git a/skolehjem/public/css/webapp.css b/skolehjem/public/css/webapp.css
index 74ff2cf..0cc6c66 100644
--- a/skolehjem/public/css/webapp.css
+++ b/skolehjem/public/css/webapp.css
@@ -31,6 +31,8 @@ form {
   font-size: 25px;
   color: grey;
   margin: 7.5px 0 0 -45px;
+  align-self: center;
+  z-index: 98;
 }
 
 .btn {
@@ -104,6 +106,23 @@ input.appinput {
   color: white;
 }
 
+.form-control {
+  flex: 1 1 auto;
+  width: 1%;
+}
+
+.input-group {
+  position: relative;
+  display: flex;
+  flex-wrap: wrap;
+  align-items: stretch;
+  width: 100%;
+}
+
+.input-group-append {
+  display: flex;
+}
+
 .d-flex {
   display: flex;
 }
diff --git a/skolehjem/resources/sass/app/forms/_forms.scss b/skolehjem/resources/sass/app/forms/_forms.scss
index 2eaf11a..c2e3c74 100644
--- a/skolehjem/resources/sass/app/forms/_forms.scss
+++ b/skolehjem/resources/sass/app/forms/_forms.scss
@@ -11,6 +11,8 @@ form {
     font-size: 25px;
     color: grey;
     margin: 7.5px 0 0 -45px;
+    align-self: center;
+    z-index: 98;
 }
 
 .btn {
@@ -67,3 +69,23 @@ input.appinput {
     opacity: 1;
     color: white;
 }
+
+.form-control {
+    flex: 1 1 auto;
+    width: 1%;
+}
+
+.input-group {
+    position: relative;
+    display: -ms-flexbox;
+    display: flex;
+    -ms-flex-wrap: wrap;
+    flex-wrap: wrap;
+    -ms-flex-align: stretch;
+    align-items: stretch;
+    width: 100%;
+}
+
+.input-group-append {
+    display: flex;
+}
diff --git a/skolehjem/resources/views/app/users/editpass.blade.php b/skolehjem/resources/views/app/users/editpass.blade.php
index 43b0654..0cb2cfb 100644
--- a/skolehjem/resources/views/app/users/editpass.blade.php
+++ b/skolehjem/resources/views/app/users/editpass.blade.php
@@ -7,18 +7,30 @@
 @section("content")
     <main>
         <h1 class="text-center sde-blue mt-0">Konto</h1>
-        <form method="post" action="{{ route("users.update", ['user' => Auth::user()]) }}" style="display: inline-table;">
+        <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" placeholder="******">
-            <span class="fa fa-fw fa-eye field-icon toggle-password" id="fa-old" onclick="show('old', 'fa-old')"></span>
+            <div class="input-group text-left">
+                <input type="password" class="form-control" name="oldpassword" id="old" placeholder="******">
+                <div class="input-group-append">
+                    <span class="fa fa-fw fa-eye field-icon toggle-password" id="fa-old" onclick="show('old', 'fa-old')"></span>
+                </div>
+            </div>
             <span>Nyt Password:</span>
-            <input class="w-100" type="password" name="password" id="new" placeholder="******" required style="width: calc(100% - 8px)">
-            <span class="fa fa-fw fa-eye field-icon toggle-password" id="fa-new" onclick="show('new', 'fa-new')"></span>
+            <div class="input-group text-left">
+                <input type="password" class="form-control" name="password" id="new" placeholder="******" required>
+                <div class="input-group-append">
+                    <span class="fa fa-fw fa-eye field-icon toggle-password" id="fa-new" onclick="show('new', 'fa-new')"></span>
+                </div>
+            </div>
             <span>Bekræft Nyt Password:</span>
-            <input class="w-100" type="password" name="confirmpassword" id="confirm" placeholder="******" required style="width: calc(100% - 8px)">
-            <span class="fa fa-fw fa-eye field-icon toggle-password" id="fa-confirm" onclick="show('confirm', 'fa-confirm')"></span>
+            <div class="input-group text-left">
+                <input type="password" class="form-control" name="confirmpassword" id="confirm" placeholder="******" required>
+                <div class="input-group-append">
+                    <span class="fa fa-fw fa-eye field-icon toggle-password" id="fa-confirm" onclick="show('confirm', 'fa-confirm')"></span>
+                </div>
+            </div>
             {!! session()->get('error#notsamepass') !!}
             {!! session()->get('error#oldpass') !!}
             <button type="submit" class="btn text-center btn-sde-blue mt-1">Rediger</button>

From 93198e5a545dc58d71781ae34b0cc2d81434493f Mon Sep 17 00:00:00 2001
From: frederikpyt <frederikpyt@gmail.com>
Date: Mon, 3 Aug 2020 09:53:57 +0200
Subject: [PATCH 10/10] Fixed css

---
 skolehjem/public/css/admin.css                       |  4 ++--
 skolehjem/public/css/webapp.css                      |  4 ++--
 skolehjem/resources/sass/app/forms/_forms.scss       |  4 ++--
 .../resources/views/app/users/editpass.blade.php     | 12 +++---------
 4 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/skolehjem/public/css/admin.css b/skolehjem/public/css/admin.css
index 4303884..507ef22 100644
--- a/skolehjem/public/css/admin.css
+++ b/skolehjem/public/css/admin.css
@@ -27,12 +27,12 @@ form {
 }
 
 .fa-eye {
-  position: absolute;
   font-size: 25px;
   color: grey;
-  margin: 7.5px 0 0 -45px;
+  margin: 0 0 16px -35px;
   align-self: center;
   z-index: 98;
+  background-color: white;
 }
 
 .btn {
diff --git a/skolehjem/public/css/webapp.css b/skolehjem/public/css/webapp.css
index 0cc6c66..b5c435a 100644
--- a/skolehjem/public/css/webapp.css
+++ b/skolehjem/public/css/webapp.css
@@ -27,12 +27,12 @@ form {
 }
 
 .fa-eye {
-  position: absolute;
   font-size: 25px;
   color: grey;
-  margin: 7.5px 0 0 -45px;
+  margin: 0 0 16px -35px;
   align-self: center;
   z-index: 98;
+  background-color: white;
 }
 
 .btn {
diff --git a/skolehjem/resources/sass/app/forms/_forms.scss b/skolehjem/resources/sass/app/forms/_forms.scss
index c2e3c74..e270bfe 100644
--- a/skolehjem/resources/sass/app/forms/_forms.scss
+++ b/skolehjem/resources/sass/app/forms/_forms.scss
@@ -7,12 +7,12 @@ form {
 }
 
 .fa-eye {
-    position: absolute;
     font-size: 25px;
     color: grey;
-    margin: 7.5px 0 0 -45px;
+    margin: 0 0 16px -35px;
     align-self: center;
     z-index: 98;
+    background-color: white;
 }
 
 .btn {
diff --git a/skolehjem/resources/views/app/users/editpass.blade.php b/skolehjem/resources/views/app/users/editpass.blade.php
index 620a070..bb0f78a 100644
--- a/skolehjem/resources/views/app/users/editpass.blade.php
+++ b/skolehjem/resources/views/app/users/editpass.blade.php
@@ -13,23 +13,17 @@
             <span>Nuværende Password:</span>
             <div class="input-group text-left">
                 <input type="password" class="form-control" name="oldpassword" id="old" placeholder="******">
-                <div class="input-group-append">
-                    <span class="fa fa-fw fa-eye field-icon toggle-password" id="fa-old" onclick="show('old', 'fa-old')"></span>
-                </div>
+                <span class="fa fa-fw fa-eye field-icon toggle-password" id="fa-old" onclick="show('old', 'fa-old')"></span>
             </div>
             <span>Nyt Password:</span>
             <div class="input-group text-left">
                 <input type="password" class="form-control" name="password" id="new" placeholder="******" required>
-                <div class="input-group-append">
-                    <span class="fa fa-fw fa-eye field-icon toggle-password" id="fa-new" onclick="show('new', 'fa-new')"></span>
-                </div>
+                <span class="fa fa-fw fa-eye field-icon toggle-password" id="fa-new" onclick="show('new', 'fa-new')"></span>
             </div>
             <span>Bekræft Nyt Password:</span>
             <div class="input-group text-left">
                 <input type="password" class="form-control" name="confirmpassword" id="confirm" placeholder="******" required>
-                <div class="input-group-append">
-                    <span class="fa fa-fw fa-eye field-icon toggle-password" id="fa-confirm" onclick="show('confirm', 'fa-confirm')"></span>
-                </div>
+                <span class="fa fa-fw fa-eye field-icon toggle-password" id="fa-confirm" onclick="show('confirm', 'fa-confirm')"></span>
             </div>
             {!! session()->get('error#notsamepass') !!}
             {!! session()->get('error#oldpass') !!}