|
@@ -18,6 +18,7 @@
|
|
|
|
|
|
import Advanced from './Settings/Advanced.svelte';
|
|
import Advanced from './Settings/Advanced.svelte';
|
|
import Modal from '../common/Modal.svelte';
|
|
import Modal from '../common/Modal.svelte';
|
|
|
|
+ import { updateUserPassword } from '$lib/apis/auths';
|
|
|
|
|
|
export let show = false;
|
|
export let show = false;
|
|
|
|
|
|
@@ -600,6 +601,31 @@
|
|
return models;
|
|
return models;
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+ const updatePasswordHandler = async () => {
|
|
|
|
+ if (newPassword === newPasswordConfirm) {
|
|
|
|
+ const res = await updateUserPassword(localStorage.token, currentPassword, newPassword).catch(
|
|
|
|
+ (error) => {
|
|
|
|
+ toast.error(error);
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ if (res) {
|
|
|
|
+ toast.success('Successfully updated.');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ currentPassword = '';
|
|
|
|
+ newPassword = '';
|
|
|
|
+ newPasswordConfirm = '';
|
|
|
|
+ } else {
|
|
|
|
+ toast.error(
|
|
|
|
+ `The passwords you entered don't quite match. Please double-check and try again.`
|
|
|
|
+ );
|
|
|
|
+ newPassword = '';
|
|
|
|
+ newPasswordConfirm = '';
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
onMount(async () => {
|
|
onMount(async () => {
|
|
let settings = JSON.parse(localStorage.getItem('settings') ?? '{}');
|
|
let settings = JSON.parse(localStorage.getItem('settings') ?? '{}');
|
|
console.log(settings);
|
|
console.log(settings);
|
|
@@ -1852,7 +1878,7 @@
|
|
<form
|
|
<form
|
|
class="flex flex-col h-full text-sm"
|
|
class="flex flex-col h-full text-sm"
|
|
on:submit|preventDefault={() => {
|
|
on:submit|preventDefault={() => {
|
|
- console.log('change save');
|
|
|
|
|
|
+ updatePasswordHandler();
|
|
}}
|
|
}}
|
|
>
|
|
>
|
|
<div class=" mb-2.5 font-medium">Change Password</div>
|
|
<div class=" mb-2.5 font-medium">Change Password</div>
|