diff --git a/src/components/input/password.vue b/src/components/input/password.vue
new file mode 100644
index 00000000..b8c2fee4
--- /dev/null
+++ b/src/components/input/password.vue
@@ -0,0 +1,85 @@
+
+
+
$emit('submit', e)"
+ :tabindex="props.tabindex"
+ @focusout="validate"
+ @input="handleInput"
+ />
+
+
+
+
+
+ {{ $t('user.auth.passwordRequired') }}
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/styles/components/_index.scss b/src/styles/components/_index.scss
index 4511d1ca..323769b4 100644
--- a/src/styles/components/_index.scss
+++ b/src/styles/components/_index.scss
@@ -4,4 +4,3 @@
@import "task";
@import "tasks";
@import "namespaces";
-@import 'password-field-toggle';
diff --git a/src/styles/components/password-field-toggle.scss b/src/styles/components/password-field-toggle.scss
deleted file mode 100644
index 52d95ba5..00000000
--- a/src/styles/components/password-field-toggle.scss
+++ /dev/null
@@ -1,7 +0,0 @@
-.password-field-type-toggle {
- position: absolute;
- color: var(--grey-400);
- top: 50%;
- right: 1rem;
- transform: translateY(-50%);
-}
diff --git a/src/views/user/Login.vue b/src/views/user/Login.vue
index 9150fb4b..5c3153bf 100644
--- a/src/views/user/Login.vue
+++ b/src/views/user/Login.vue
@@ -39,31 +39,7 @@
{{ $t('user.auth.forgotPassword') }}
-
-
- {{ $t('user.auth.passwordRequired') }}
-
+
@@ -87,7 +63,6 @@
@click="submit"
:loading="loading"
tabindex="4"
- :disabled="!allFieldsValid"
>
{{ $t('user.auth.login') }}
@@ -129,9 +104,11 @@ import {getErrorText} from '@/message'
import Message from '@/components/misc/message'
import {redirectToProvider} from '../../helpers/redirectToProvider'
import {getLastVisited, clearLastVisited} from '../../helpers/saveLastVisited'
+import Password from '@/components/input/password'
export default {
components: {
+ Password,
Message,
},
data() {
@@ -139,8 +116,8 @@ export default {
confirmedEmailSuccess: false,
errorMessage: '',
usernameValid: true,
- passwordValid: true,
- passwordFieldType: 'password',
+ password: '',
+ validatePasswordInitially: false,
}
},
beforeMount() {
@@ -185,9 +162,6 @@ export default {
this.openidConnect.providers &&
this.openidConnect.providers.length > 0
},
- allFieldsValid() {
- return this.usernameValid && this.passwordValid
- },
...mapState({
registrationEnabled: state => state.config.registrationEnabled,
loading: LOADING,
@@ -215,12 +189,6 @@ export default {
}
},
- togglePasswordFieldType() {
- this.passwordFieldType = this.passwordFieldType === 'password'
- ? 'text'
- : 'password'
- },
-
async submit() {
this.errorMessage = ''
// Some browsers prevent Vue bindings from working with autofilled values.
@@ -228,13 +196,13 @@ export default {
// For more info, see https://kolaente.dev/vikunja/frontend/issues/78
const credentials = {
username: this.$refs.username.value,
- password: this.$refs.password.value,
+ password: this.password,
}
if (credentials.username === '' || credentials.password === '') {
// Trigger the validation error messages
this.validateField('username')
- this.validateField('password')
+ this.validatePasswordInitially = true
return
}
diff --git a/src/views/user/Register.vue b/src/views/user/Register.vue
index 10a306ae..0d7172d4 100644
--- a/src/views/user/Register.vue
+++ b/src/views/user/Register.vue
@@ -46,30 +46,7 @@
-
-
- {{ $t('user.auth.passwordRequired') }}
-
+
credentials.password = v" :validate-initially="validatePasswordInitially"/>
import {useDebounceFn} from '@vueuse/core'
-import {ref, reactive, toRaw, computed, onBeforeMount} from 'vue'
+import {ref, reactive, toRaw, computed, onBeforeMount, watch} from 'vue'
import router from '@/router'
import {store} from '@/store'
import Message from '@/components/misc/message'
import {isEmail} from '@/helpers/isEmail'
+import Password from '@/components/input/password'
// FIXME: use the `beforeEnter` hook of vue-router
// Check if the user is already logged in, if so, redirect them to the homepage
@@ -116,6 +94,7 @@ const credentials = reactive({
const loading = computed(() => store.state.loading)
const errorMessage = ref('')
+const validatePasswordInitially = ref(false)
const DEBOUNCE_TIME = 100
@@ -130,29 +109,17 @@ const validateUsername = useDebounceFn(() => {
usernameValid.value = credentials.username !== ''
}, DEBOUNCE_TIME)
-const passwordValid = ref(true)
-const validatePassword = useDebounceFn(() => {
- passwordValid.value = credentials.password !== ''
-}, DEBOUNCE_TIME)
-
const everythingValid = computed(() => {
return credentials.username !== '' &&
credentials.email !== '' &&
credentials.password !== '' &&
emailValid.value &&
- usernameValid.value &&
- passwordValid.value
+ usernameValid.value
})
-const passwordFieldType = ref('password')
-const togglePasswordFieldType = () => {
- passwordFieldType.value = passwordFieldType.value === 'password'
- ? 'text'
- : 'password'
-}
-
async function submit() {
errorMessage.value = ''
+ validatePasswordInitially.value = true
if (!everythingValid.value) {
return