diff --git a/front/src/components/auth/Settings.vue b/front/src/components/auth/Settings.vue index c847bde888efb2a0b3bca619dd5cc17e6c3b62d4..8eeae85a94a0831f2008428d92b4712547b0533a 100644 --- a/front/src/components/auth/Settings.vue +++ b/front/src/components/auth/Settings.vue @@ -35,21 +35,13 @@ </div> <div class="field"> <label><i18next path="Old password"/></label> - <input - required - type="password" - autofocus - placeholder="Enter your old password" - v-model="old_password"> + <password-input required v-model="old_password" /> + </div> <div class="field"> <label><i18next path="New password"/></label> - <input - required - type="password" - autofocus - placeholder="Enter your new password" - v-model="new_password"> + <password-input required v-model="new_password" /> + </div> <button :class="['ui', {'loading': isLoading}, 'button']" type="submit"><i18next path="Change password"/></button> </form> @@ -62,8 +54,12 @@ import $ from 'jquery' import axios from 'axios' import logger from '@/logging' +import PasswordInput from '@/components/forms/PasswordInput' export default { + components: { + PasswordInput + }, data () { let d = { // We need to initialize the component with any diff --git a/front/src/components/auth/Signup.vue b/front/src/components/auth/Signup.vue index 57966264f99f0aa732f5ecd306bc6d875f9ca9fc..89f4cb1f1266c956283142cfc4f470e3b0c5d031 100644 --- a/front/src/components/auth/Signup.vue +++ b/front/src/components/auth/Signup.vue @@ -34,16 +34,7 @@ </div> <div class="field"> <i18next tag="label" path="Password"/> - <div class="ui action input"> - <input - required - :type="passwordInputType" - placeholder="Enter your password" - v-model="password"> - <span @click="showPassword = !showPassword" title="Show/hide password" class="ui icon button"> - <i class="eye icon"></i> - </span> - </div> + <password-input v-model="password" /> </div> <button :class="['ui', 'green', {'loading': isLoading}, 'button']" type="submit"><i18next path="Create my account"/></button> </form> @@ -57,8 +48,13 @@ import axios from 'axios' import logger from '@/logging' +import PasswordInput from '@/components/forms/PasswordInput' + export default { name: 'login', + components: { + PasswordInput + }, props: { next: {type: String, default: '/'} }, @@ -69,8 +65,7 @@ export default { password: '', isLoadingInstanceSetting: true, errors: [], - isLoading: false, - showPassword: false + isLoading: false } }, created () { @@ -104,16 +99,7 @@ export default { self.isLoading = false }) } - }, - computed: { - passwordInputType () { - if (this.showPassword) { - return 'text' - } - return 'password' - } } - } </script> diff --git a/front/src/components/forms/PasswordInput.vue b/front/src/components/forms/PasswordInput.vue new file mode 100644 index 0000000000000000000000000000000000000000..624a92d87c8d204ec9b8e40b247e1e7835ed5951 --- /dev/null +++ b/front/src/components/forms/PasswordInput.vue @@ -0,0 +1,31 @@ +<template> + <div class="ui action input"> + <input + required + :tabindex="index" + :type="passwordInputType" + @input="$emit('input', $event.target.value)" + :value="value"> + <span @click="showPassword = !showPassword" :title="$t('Show/hide password')" class="ui icon button"> + <i class="eye icon"></i> + </span> + </div> +</template> +<script> +export default { + props: ['value', 'index'], + data () { + return { + showPassword: false + } + }, + computed: { + passwordInputType () { + if (this.showPassword) { + return 'text' + } + return 'password' + } + } +} +</script>