Client - allow password display
This commit is contained in:
parent
d8c4106fcf
commit
9bb894dc03
60
fittrackee_client/src/components/Common/PasswordInput.vue
Normal file
60
fittrackee_client/src/components/Common/PasswordInput.vue
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<template>
|
||||||
|
<div class="password-input">
|
||||||
|
<input
|
||||||
|
:disabled="disabled"
|
||||||
|
:placeholder="placeholder"
|
||||||
|
:required="required"
|
||||||
|
:type="showPassword ? 'text' : 'password'"
|
||||||
|
minlength="8"
|
||||||
|
@input="updatePassword"
|
||||||
|
@invalid="invalidPassword"
|
||||||
|
/>
|
||||||
|
<span class="show-password" @click="togglePassword">
|
||||||
|
{{ $t(`user.${showPassword ? 'HIDE' : 'SHOW'}_PASSWORD`) }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, toRefs, withDefaults } from 'vue'
|
||||||
|
interface Props {
|
||||||
|
disabled?: boolean
|
||||||
|
placeholder?: string
|
||||||
|
required?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
|
disabled: false,
|
||||||
|
required: false,
|
||||||
|
})
|
||||||
|
const { disabled, placeholder, required } = toRefs(props)
|
||||||
|
const showPassword = ref(false)
|
||||||
|
|
||||||
|
const emit = defineEmits(['updatePassword', 'passwordError'])
|
||||||
|
|
||||||
|
function togglePassword() {
|
||||||
|
showPassword.value = !showPassword.value
|
||||||
|
}
|
||||||
|
function updatePassword(event: Event & { target: HTMLInputElement }) {
|
||||||
|
emit('updatePassword', event.target.value)
|
||||||
|
}
|
||||||
|
function invalidPassword() {
|
||||||
|
emit('passwordError')
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
@import '~@/scss/vars.scss';
|
||||||
|
|
||||||
|
.password-input {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
.show-password {
|
||||||
|
font-style: italic;
|
||||||
|
font-size: 0.85em;
|
||||||
|
margin-top: -0.75 * $default-margin;
|
||||||
|
padding-left: $default-padding;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
@ -20,11 +20,10 @@
|
|||||||
</label>
|
</label>
|
||||||
<label class="form-items" for="password">
|
<label class="form-items" for="password">
|
||||||
{{ $t('user.PASSWORD') }}
|
{{ $t('user.PASSWORD') }}
|
||||||
<input
|
<PasswordInput
|
||||||
id="password"
|
id="password"
|
||||||
type="password"
|
|
||||||
v-model="userForm.password"
|
|
||||||
:disabled="loading"
|
:disabled="loading"
|
||||||
|
@updatePassword="updatePassword"
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
<hr />
|
<hr />
|
||||||
@ -96,6 +95,7 @@
|
|||||||
onMounted,
|
onMounted,
|
||||||
} from 'vue'
|
} from 'vue'
|
||||||
|
|
||||||
|
import PasswordInput from '@/components/Common/PasswordInput.vue'
|
||||||
import { AUTH_USER_STORE, ROOT_STORE } from '@/store/constants'
|
import { AUTH_USER_STORE, ROOT_STORE } from '@/store/constants'
|
||||||
import { IUserProfile, IUserPayload } from '@/types/user'
|
import { IUserProfile, IUserPayload } from '@/types/user'
|
||||||
import { useStore } from '@/use/useStore'
|
import { useStore } from '@/use/useStore'
|
||||||
@ -147,6 +147,9 @@
|
|||||||
function updateBio(value: string) {
|
function updateBio(value: string) {
|
||||||
userForm.bio = value
|
userForm.bio = value
|
||||||
}
|
}
|
||||||
|
function updatePassword(password: string) {
|
||||||
|
userForm.password = password
|
||||||
|
}
|
||||||
function updateProfile() {
|
function updateProfile() {
|
||||||
store.dispatch(AUTH_USER_STORE.ACTIONS.UPDATE_USER_PROFILE, userForm)
|
store.dispatch(AUTH_USER_STORE.ACTIONS.UPDATE_USER_PROFILE, userForm)
|
||||||
}
|
}
|
||||||
@ -158,9 +161,20 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss" scoped>
|
||||||
@import '~@/scss/vars.scss';
|
@import '~@/scss/vars.scss';
|
||||||
|
|
||||||
|
.form-items {
|
||||||
|
.password-input {
|
||||||
|
::v-deep(.show-password) {
|
||||||
|
font-weight: normal;
|
||||||
|
font-size: 0.8em;
|
||||||
|
margin-top: -4px;
|
||||||
|
padding-left: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.form-buttons {
|
.form-buttons {
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
@media screen and (max-width: $x-small-limit) {
|
@media screen and (max-width: $x-small-limit) {
|
||||||
|
@ -42,20 +42,17 @@
|
|||||||
: $t('user.EMAIL')
|
: $t('user.EMAIL')
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
<input
|
<PasswordInput
|
||||||
v-if="action !== 'reset-request'"
|
v-if="action !== 'reset-request'"
|
||||||
id="password"
|
|
||||||
:disabled="registration_disabled"
|
:disabled="registration_disabled"
|
||||||
required
|
:required="true"
|
||||||
@invalid="invalidateForm"
|
|
||||||
type="password"
|
|
||||||
minlength="8"
|
|
||||||
v-model="formData.password"
|
|
||||||
:placeholder="
|
:placeholder="
|
||||||
action === 'reset'
|
action === 'reset'
|
||||||
? $t('user.ENTER_PASSWORD')
|
? $t('user.ENTER_PASSWORD')
|
||||||
: $t('user.PASSWORD')
|
: $t('user.PASSWORD')
|
||||||
"
|
"
|
||||||
|
@updatePassword="updatePassword"
|
||||||
|
@passwordError="invalidateForm"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" :disabled="registration_disabled">
|
<button type="submit" :disabled="registration_disabled">
|
||||||
@ -95,6 +92,7 @@
|
|||||||
} from 'vue'
|
} from 'vue'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
|
|
||||||
|
import PasswordInput from '@/components/Common/PasswordInput.vue'
|
||||||
import { AUTH_USER_STORE, ROOT_STORE } from '@/store/constants'
|
import { AUTH_USER_STORE, ROOT_STORE } from '@/store/constants'
|
||||||
import { TAppConfig } from '@/types/application'
|
import { TAppConfig } from '@/types/application'
|
||||||
import { ILoginRegisterFormData } from '@/types/user'
|
import { ILoginRegisterFormData } from '@/types/user'
|
||||||
@ -144,6 +142,9 @@
|
|||||||
function invalidateForm() {
|
function invalidateForm() {
|
||||||
formErrors.value = true
|
formErrors.value = true
|
||||||
}
|
}
|
||||||
|
function updatePassword(password: string) {
|
||||||
|
formData.password = password
|
||||||
|
}
|
||||||
function onSubmit(actionType: string) {
|
function onSubmit(actionType: string) {
|
||||||
switch (actionType) {
|
switch (actionType) {
|
||||||
case 'reset':
|
case 'reset':
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
"EMAIL": "Email",
|
"EMAIL": "Email",
|
||||||
"ENTER_EMAIL": "Enter an email address",
|
"ENTER_EMAIL": "Enter an email address",
|
||||||
"ENTER_PASSWORD": "Enter a password",
|
"ENTER_PASSWORD": "Enter a password",
|
||||||
|
"HIDE_PASSWORD": "hide password",
|
||||||
"INVALID_TOKEN": "Invalid token, please request a new password reset.",
|
"INVALID_TOKEN": "Invalid token, please request a new password reset.",
|
||||||
"LANGUAGE": "Language",
|
"LANGUAGE": "Language",
|
||||||
"LOGIN": "Login",
|
"LOGIN": "Login",
|
||||||
@ -60,6 +61,7 @@
|
|||||||
"REGISTER": "Register",
|
"REGISTER": "Register",
|
||||||
"REGISTER_DISABLED": "Sorry, registration is disabled.",
|
"REGISTER_DISABLED": "Sorry, registration is disabled.",
|
||||||
"RESET_PASSWORD": "Reset your password",
|
"RESET_PASSWORD": "Reset your password",
|
||||||
|
"SHOW_PASSWORD": "show password",
|
||||||
"USER_PICTURE": "user picture",
|
"USER_PICTURE": "user picture",
|
||||||
"USERNAME": "Username"
|
"USERNAME": "Username"
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
"EMAIL": "Email",
|
"EMAIL": "Email",
|
||||||
"ENTER_EMAIL": "Saisir une adresse email",
|
"ENTER_EMAIL": "Saisir une adresse email",
|
||||||
"ENTER_PASSWORD": "Saisir un mot de passe",
|
"ENTER_PASSWORD": "Saisir un mot de passe",
|
||||||
|
"HIDE_PASSWORD": "masquer le mot de passe",
|
||||||
"INVALID_TOKEN": "Jeton invalide, veullez demander une nouvelle réinitialisation de mot de passe.",
|
"INVALID_TOKEN": "Jeton invalide, veullez demander une nouvelle réinitialisation de mot de passe.",
|
||||||
"LANGUAGE": "Langue",
|
"LANGUAGE": "Langue",
|
||||||
"LOGIN": "Se connecter",
|
"LOGIN": "Se connecter",
|
||||||
@ -60,6 +61,7 @@
|
|||||||
"REGISTER": "S'inscrire",
|
"REGISTER": "S'inscrire",
|
||||||
"REGISTER_DISABLED": "Désolé, les inscriptions sont désactivées.",
|
"REGISTER_DISABLED": "Désolé, les inscriptions sont désactivées.",
|
||||||
"RESET_PASSWORD": "Réinitialiser votre mot de passe",
|
"RESET_PASSWORD": "Réinitialiser votre mot de passe",
|
||||||
|
"SHOW_PASSWORD": "afficher le mot de passe",
|
||||||
"USER_PICTURE": "photo de l'utilisateur",
|
"USER_PICTURE": "photo de l'utilisateur",
|
||||||
"USERNAME": "Nom d'utilisateur"
|
"USERNAME": "Nom d'utilisateur"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user