From 26af63a80b185c245d1da722c72e58613a409f18 Mon Sep 17 00:00:00 2001 From: NGPixel Date: Mon, 20 Jul 2020 00:22:29 -0400 Subject: [PATCH] fix: login input hints --- client/components/login.vue | 31 +++++++++++++++---- server/graph/schemas/authentication.graphql | 2 +- .../authentication/ldap/definition.yml | 2 +- .../authentication/local/definition.yml | 2 +- 4 files changed, 28 insertions(+), 9 deletions(-) diff --git a/client/components/login.vue b/client/components/login.vue index b777d54f..e2ebcc29 100644 --- a/client/components/login.vue +++ b/client/components/login.vue @@ -40,7 +40,9 @@ hide-details ref='iptEmail' v-model='username' - :placeholder='$t(selectedStrategy.strategy.usernameLabel)' + :placeholder='isUsernameEmail ? $t(`auth:fields.email`) : $t(`auth:fields.username`)' + :type='isUsernameEmail ? `email` : `text`' + :autocomplete='isUsernameEmail ? `email` : `username`' ) v-text-field.mt-2( solo @@ -54,6 +56,7 @@ @click:append='() => (hidePassword = !hidePassword)' :type='hidePassword ? "password" : "text"' :placeholder='$t("auth:fields.password")' + autocomplete='current-password' @keyup.enter='login' ) v-btn.mt-2.text-none( @@ -95,7 +98,9 @@ hide-details ref='iptForgotPwdEmail' v-model='username' - :placeholder='$t(selectedStrategy.strategy.usernameLabel)' + :placeholder='$t(`auth:fields.email`)' + type='email' + autocomplete='email' ) v-btn.mt-2.text-none( width='100%' @@ -130,6 +135,7 @@ ref='iptNewPassword' v-model='newPassword' :placeholder='$t(`auth:changePwd.newPasswordPlaceholder`)' + autocomplete='new-password' ) password-strength(slot='progress', v-model='newPassword') v-text-field.mt-2( @@ -141,6 +147,7 @@ hide-details v-model='newPasswordVerify' :placeholder='$t(`auth:changePwd.newPasswordVerifyPlaceholder`)' + autocomplete='new-password' @keyup.enter='changePassword' ) v-btn.mt-2.text-none( @@ -168,6 +175,7 @@ ref='iptTFA' v-model='securityCode' :placeholder='$t("auth:tfa.placeholder")' + autocomplete='one-time-code' @keyup.enter='verifySecurityCode' ) v-btn.mt-2.text-none( @@ -210,7 +218,7 @@ export default { error: false, strategies: [], selectedStrategyKey: 'unselected', - selectedStrategy: { key: 'unselected', strategy: { useForm: false } }, + selectedStrategy: { key: 'unselected', strategy: { useForm: false, usernameType: 'email' } }, screen: 'login', username: '', password: '', @@ -242,6 +250,9 @@ export default { } else { return this.strategies } + }, + isUsernameEmail () { + return this.selectedStrategy.strategy.usernameType === `email` } }, watch: { @@ -403,7 +414,15 @@ export default { icon: 'check' }) _.delay(() => { - window.location.replace('/') // TEMPORARY - USE RETURNURL + const loginRedirect = Cookies.get('loginRedirect') + if (loginRedirect) { + Cookies.remove('loginRedirect') + window.location.replace(loginRedirect) + } else if (respObj.redirect) { + window.location.replace(respObj.redirect) + } else { + window.location.replace('/') + } }, 1000) this.isLoading = false } else { @@ -467,7 +486,7 @@ export default { forgotPassword () { this.screen = 'forgot' this.$nextTick(() => { - this.$refs.iptEmailForgot.focus() + this.$refs.iptForgotPwdEmail.focus() }) }, /** @@ -494,7 +513,7 @@ export default { color icon useForm - usernameLabel + usernameType } displayName order diff --git a/server/graph/schemas/authentication.graphql b/server/graph/schemas/authentication.graphql index 97e95f6e..a1a22ae7 100644 --- a/server/graph/schemas/authentication.graphql +++ b/server/graph/schemas/authentication.graphql @@ -85,7 +85,7 @@ type AuthenticationStrategy { description: String isAvailable: Boolean useForm: Boolean! - usernameLabel: String + usernameType: String logo: String color: String website: String diff --git a/server/modules/authentication/ldap/definition.yml b/server/modules/authentication/ldap/definition.yml index 9ef50e84..40710e26 100644 --- a/server/modules/authentication/ldap/definition.yml +++ b/server/modules/authentication/ldap/definition.yml @@ -7,7 +7,7 @@ color: blue darken-3 website: https://www.microsoft.com/windowsserver isAvailable: true useForm: true -usernameLabel: 'auth:fields.username' +usernameType: username props: url: title: LDAP URL diff --git a/server/modules/authentication/local/definition.yml b/server/modules/authentication/local/definition.yml index f2977e36..e4157ed6 100644 --- a/server/modules/authentication/local/definition.yml +++ b/server/modules/authentication/local/definition.yml @@ -7,5 +7,5 @@ color: primary website: https://wiki.js.org isAvailable: true useForm: true -usernameLabel: 'auth:fields.email' +usernameType: email props: {}