diff --git a/src/components/settings/Settings.svelte b/src/components/settings/Settings.svelte index 1ad352ed..65d7615d 100644 --- a/src/components/settings/Settings.svelte +++ b/src/components/settings/Settings.svelte @@ -15,7 +15,8 @@ JSON.stringify(editable) === JSON.stringify(original_data) ); $: save_enabled = changes_performed && isEmail(editable.email); - $: update_password_enabled = password_change.length > 0 &&(password_change === password_confirm); + $: update_password_enabled = + password_change.length > 0 && password_change === password_confirm; const user_promise = MeService.meControllerGet().then((data) => { data_loaded = true; data.groups = data.groups.map((g) => g.id); @@ -29,10 +30,8 @@ text: $_("updating-your-profile"), duration: 2500, }).showToast(); - console.log(editable); MeService.meControllerPut(editable) .then((resp) => { - console.log(resp); original_data = Object.assign(original_data, editable); Toastify({ text: $_("profile-updated"), @@ -43,9 +42,30 @@ .catch((err) => {}); } } + function changePassword() { + if (data_loaded === true && update_password_enabled) { + Toastify({ + text: "Changing your password", + duration: 2500, + }).showToast(); + let postdata = Object.assign({}, original_data); + postdata.password = password_confirm; + MeService.meControllerPut(postdata) + .then((resp) => { + password_confirm = ""; + password_change = ""; + Toastify({ + text: "Password changed", + duration: 2500, + backgroundColor: "linear-gradient(to right, #00b09b, #96c93d)", + }).showToast(); + }) + .catch((err) => {}); + } + } - +

+ for="new_password" + class="font-medium text-gray-700">{$_('new-password')}
+ for="new_password" + class="font-medium text-gray-700">{$_('confirm-the-new-password')}
- {#if (password_change != password_confirm) && password_change.length>0} + {#if password_change != password_confirm && password_change.length > 0} {$_('passwords-dont-match')} {/if} @@ -228,7 +248,7 @@ type="submit" disabled={!update_password_enabled} class:opacity-50={!update_password_enabled} - on:click={submit} + on:click={changePassword} class="w-full justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-blue-600 text-base font-medium text-white hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 sm:ml-3 sm:w-auto sm:text-sm"> {$_('update-password')} @@ -259,26 +279,26 @@
- {#if delete_triggered} - - - {/if} - {#if !delete_triggered} - - {/if} + {#if delete_triggered} + + + {/if} + {#if !delete_triggered} + + {/if}