API - add current password check when modifying it
This commit is contained in:
@ -18,18 +18,29 @@
|
||||
<input id="email" :value="user.email" disabled />
|
||||
</label>
|
||||
<label class="form-items" for="password-field">
|
||||
{{ $t('user.PASSWORD') }}
|
||||
{{ $t('user.CURRENT_PASSWORD') }}*
|
||||
<PasswordInput
|
||||
id="password-field"
|
||||
:disabled="loading"
|
||||
:checkStrength="true"
|
||||
:password="userForm.password"
|
||||
:isSuccess="false"
|
||||
:required="true"
|
||||
@updatePassword="updatePassword"
|
||||
@passwordError="invalidateForm"
|
||||
/>
|
||||
</label>
|
||||
<label class="form-items" for="new-password-field">
|
||||
{{ $t('user.NEW_PASSWORD') }}*
|
||||
<PasswordInput
|
||||
id="new-password-field"
|
||||
:disabled="loading"
|
||||
:checkStrength="true"
|
||||
:password="userForm.new_password"
|
||||
:isSuccess="false"
|
||||
:required="true"
|
||||
@updatePassword="updateNewPassword"
|
||||
@passwordError="invalidateForm"
|
||||
/>
|
||||
</label>
|
||||
<div class="form-buttons">
|
||||
<button class="confirm" type="submit">
|
||||
{{ $t('buttons.SUBMIT') }}
|
||||
@ -74,6 +85,7 @@
|
||||
const userForm: IUserAccountPayload = reactive({
|
||||
email: '',
|
||||
password: '',
|
||||
new_password: '',
|
||||
})
|
||||
const loading = computed(
|
||||
() => store.getters[AUTH_USER_STORE.GETTERS.USER_LOADING]
|
||||
@ -102,9 +114,13 @@
|
||||
function updatePassword(password: string) {
|
||||
userForm.password = password
|
||||
}
|
||||
function updateNewPassword(new_password: string) {
|
||||
userForm.new_password = new_password
|
||||
}
|
||||
function updateProfile() {
|
||||
store.dispatch(AUTH_USER_STORE.ACTIONS.UPDATE_USER_ACCOUNT, {
|
||||
password: userForm.password,
|
||||
new_password: userForm.new_password,
|
||||
})
|
||||
}
|
||||
function updateDisplayModal(value: boolean) {
|
||||
@ -114,15 +130,17 @@
|
||||
store.dispatch(AUTH_USER_STORE.ACTIONS.DELETE_ACCOUNT, { username })
|
||||
}
|
||||
|
||||
onUnmounted(() =>
|
||||
onUnmounted(() => {
|
||||
store.commit(AUTH_USER_STORE.MUTATIONS.UPDATE_IS_SUCCESS, false)
|
||||
)
|
||||
store.commit(ROOT_STORE.MUTATIONS.EMPTY_ERROR_MESSAGES)
|
||||
})
|
||||
|
||||
watch(
|
||||
() => isSuccess.value,
|
||||
async (isSuccessValue) => {
|
||||
if (isSuccessValue) {
|
||||
updatePassword('')
|
||||
updateNewPassword('')
|
||||
formErrors.value = false
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { format } from 'date-fns'
|
||||
import { ComputedRef, computed, reactive, onMounted } from 'vue'
|
||||
import { ComputedRef, computed, reactive, onMounted, onUnmounted } from 'vue'
|
||||
|
||||
import { AUTH_USER_STORE, ROOT_STORE } from '@/store/constants'
|
||||
import { IUserProfile, IUserPayload } from '@/types/user'
|
||||
@ -115,6 +115,10 @@
|
||||
function updateProfile() {
|
||||
store.dispatch(AUTH_USER_STORE.ACTIONS.UPDATE_USER_PROFILE, userForm)
|
||||
}
|
||||
|
||||
onUnmounted(() => {
|
||||
store.commit(ROOT_STORE.MUTATIONS.EMPTY_ERROR_MESSAGES)
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
@ -33,7 +33,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ComputedRef, Ref, computed, ref, toRefs } from 'vue'
|
||||
import { ComputedRef, Ref, computed, ref, toRefs, onUnmounted } from 'vue'
|
||||
|
||||
import UserPicture from '@/components/User/UserPicture.vue'
|
||||
import { AUTH_USER_STORE, ROOT_STORE } from '@/store/constants'
|
||||
@ -76,6 +76,10 @@
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
onUnmounted(() => {
|
||||
store.commit(ROOT_STORE.MUTATIONS.EMPTY_ERROR_MESSAGES)
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
@ -68,7 +68,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ComputedRef, computed, reactive, onMounted } from 'vue'
|
||||
import { ComputedRef, computed, reactive, onMounted, onUnmounted } from 'vue'
|
||||
|
||||
import TimezoneDropdown from '@/components/User/ProfileEdition/TimezoneDropdown.vue'
|
||||
import { AUTH_USER_STORE, ROOT_STORE } from '@/store/constants'
|
||||
@ -134,4 +134,8 @@
|
||||
function updateTZ(value: string) {
|
||||
userForm.timezone = value
|
||||
}
|
||||
|
||||
onUnmounted(() => {
|
||||
store.commit(ROOT_STORE.MUTATIONS.EMPTY_ERROR_MESSAGES)
|
||||
})
|
||||
</script>
|
||||
|
@ -2,6 +2,7 @@
|
||||
"ADMIN": "Admin",
|
||||
"ALREADY_HAVE_ACCOUNT": "Already have an account?",
|
||||
"CONFIRM_ACCOUNT_DELETION": "Are you sure you want to delete your account? All data will be deleted, this cannot be undone",
|
||||
"CURRENT_PASSWORD": "Current password",
|
||||
"EMAIL": "Email",
|
||||
"EMAIL_INFO": "Enter a valid email address.",
|
||||
"ENTER_PASSWORD": "Enter a password",
|
||||
@ -10,6 +11,7 @@
|
||||
"LANGUAGE": "Language",
|
||||
"LOGIN": "Login",
|
||||
"LOGOUT": "Logout",
|
||||
"NEW_PASSWORD": "New password",
|
||||
"PASSWORD": "Password",
|
||||
"PASSWORD_INFO": "At least 8 characters required.",
|
||||
"PASSWORD_FORGOTTEN": "Forgot password?",
|
||||
|
@ -2,6 +2,7 @@
|
||||
"ADMIN": "Admin",
|
||||
"ALREADY_HAVE_ACCOUNT": "Vous avez déjà un compte ?",
|
||||
"CONFIRM_ACCOUNT_DELETION": "Etes-vous sûr de vouloir supprimer votre compte ? Toutes les données seront définitivement effacés.",
|
||||
"CURRENT_PASSWORD": "Mot de passe actuel",
|
||||
"EMAIL": "Email",
|
||||
"EMAIL_INFO": "Saisir une adresse email valide.",
|
||||
"ENTER_PASSWORD": "Saisir un mot de passe",
|
||||
@ -10,6 +11,7 @@
|
||||
"LANGUAGE": "Langue",
|
||||
"LOGIN": "Se connecter",
|
||||
"LOGOUT": "Se déconnecter",
|
||||
"NEW_PASSWORD": "Nouveau mot de passe",
|
||||
"PASSWORD": "Mot de passe",
|
||||
"PASSWORD_INFO": "8 caractères minimum.",
|
||||
"PASSWORD_FORGOTTEN": "Mot de passe oublié ?",
|
||||
|
@ -36,6 +36,7 @@ export interface IUserPayload {
|
||||
export interface IUserAccountPayload {
|
||||
email?: string
|
||||
password: string
|
||||
new_password: string
|
||||
}
|
||||
|
||||
export interface IAdminUserPayload {
|
||||
|
Reference in New Issue
Block a user