diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php
index 6263345..804edca 100644
--- a/app/Http/Controllers/UserController.php
+++ b/app/Http/Controllers/UserController.php
@@ -135,7 +135,12 @@ class UserController extends Controller
public function changePassword(Request $request) {
$validated = $request->validate([
- 'password' => 'required|confirmed|min:8|regex:/[a-z]/|regex:/[A-Z]/|regex:/[0-9]/'
+ 'current_password' => 'password',
+ 'password' => 'required|confirmed|min:8|regex:/.*[a-z].*/|regex:/.*[A-Z].*/|regex:/.*[0-9].*/'
]);
+
+ $user = Auth::user();
+ $user->password = Hash::make($request->password);
+ $user->save();
}
}
diff --git a/resources/js/icons/plus-fill.vue b/resources/js/icons/plus-fill.vue
new file mode 100644
index 0000000..4a86388
--- /dev/null
+++ b/resources/js/icons/plus-fill.vue
@@ -0,0 +1,5 @@
+
+
+
diff --git a/resources/js/icons/plus.vue b/resources/js/icons/plus.vue
new file mode 100644
index 0000000..b917ed6
--- /dev/null
+++ b/resources/js/icons/plus.vue
@@ -0,0 +1,6 @@
+
+
+
diff --git a/resources/js/panel/panel.vue b/resources/js/panel/panel.vue
index 2c79099..c12c746 100644
--- a/resources/js/panel/panel.vue
+++ b/resources/js/panel/panel.vue
@@ -26,7 +26,6 @@
-
Pending Orders
@@ -87,7 +86,7 @@
Change Password
Current Password
- New Password
+ New Password
Confirm Password
@@ -129,6 +128,7 @@ function changeName() {
let pane = document.querySelector('.change-name-pane')
pane.classList.add('loading')
+ pane.classList.remove('error')
fetch("/panel/change-name", {
method: 'POST',
headers: {'Content-Type': 'application/json',
@@ -142,7 +142,7 @@ function changeName() {
info.textContent = 'Completed'
} else {
pane.classList.add('error')
- info.textContent = 'Error:' + response.status
+ info.textContent = 'Error: ' + response.status
}
pane.classList.remove('loading')
@@ -155,6 +155,7 @@ function changeEmail() {
let pane = document.querySelector('.change-email-pane')
pane.classList.add('loading')
+ pane.classList.remove('error')
fetch("/panel/change-name", {
method: 'POST',
headers: {'Content-Type': 'application/json',
@@ -163,12 +164,37 @@ function changeEmail() {
body: JSON.stringify({'email': email}),
}).then(response => {
if (response.ok) {
- response.json().then(data => {this.user = data})
pane.classList.add('completed')
info.textContent = 'Completed'
} else {
pane.classList.add('error')
- info.textContent = 'Error:' + response.status
+ info.textContent = 'Error: ' + response.status
+ }
+
+ pane.classList.remove('loading')
+ })
+}
+
+function changePassword() {
+ let info = document.querySelector('.change-password-pane span')
+ let pane = document.querySelector('.change-password-pane')
+
+ pane.classList.add('loading')
+ pane.classList.remove('error')
+ fetch("/panel/change-password", {
+ method: 'POST',
+ headers: {'Content-Type': 'application/json',
+ 'Accept': 'application/json',
+ 'X-XSRF-TOKEN': this.token},
+ body: JSON.stringify({'current_password': document.getElementById('current_password').value, 'password': document.getElementById('new_password').value, 'password_confirmation': document.getElementById('confirm_password').value}),
+ }).then(response => {
+ response.json().then(data => {console.log(data)})
+ if (response.ok) {
+ pane.classList.add('completed')
+ info.textContent = 'Completed'
+ } else {
+ pane.classList.add('error')
+ info.textContent = 'Error: ' + response.status
}
pane.classList.remove('loading')
@@ -183,6 +209,6 @@ export default {
return {active: window.location.hash, user: '',
token: '', orders: '', historyPage: 1}
},
- methods: {togglePending, toggleOrderItem, moveHistory, changeName, changeEmail}
+ methods: {togglePending, toggleOrderItem, moveHistory, changeName, changeEmail, changePassword}
}
diff --git a/resources/js/panel/sidebar.vue b/resources/js/panel/sidebar.vue
index f5af5f6..946e7e2 100644
--- a/resources/js/panel/sidebar.vue
+++ b/resources/js/panel/sidebar.vue
@@ -8,6 +8,9 @@
+
+
+