Browse Source

fix(gui): Password validation & i18n key correction

Added `_` in special character list

re #386

Signed-off-by: Pranav C <61551451+pranavxc@users.noreply.github.com>
pull/401/head
Pranav C 3 years ago
parent
commit
7cd4fda9f4
  1. 74
      packages/nc-gui/pages/user/authentication/passwordValidateMixin.js
  2. 16
      packages/nc-gui/pages/user/authentication/signup/_token.vue
  3. 53
      packages/nc-gui/pages/user/authentication/signup/index.vue
  4. 12
      packages/nc-gui/pages/user/password/reset/index.vue

74
packages/nc-gui/pages/user/authentication/passwordValidateMixin.js

@ -0,0 +1,74 @@
export default {
data: () => ({
passwordProgress: 0,
passwordValidateMsg: '',
formUtil: {
formErr: false,
formErrMsg: '',
valid: false,
valid1: false,
recpatcha: true,
e3: true,
e4: true,
passwordProgress: 0,
progressColorValue: 'red'
}
}),
methods: {
progressColor(num) {
this.formUtil.progressColorValue = ['error', 'warning', 'info', 'success'][Math.floor(num / 25)]
return this.formUtil.progressColorValue
},
PasswordValidate(p) {
if (!p) {
this.passwordProgress = 0
this.passwordValidateMsg = 'Atleast 8 letters with one Uppercase, one number and one special letter'
return false
}
let msg = ''
let validation = true
let progress = 0
if (!(p.length >= 8)) {
msg += 'Atleast 8 letters. '
validation = validation && false
} else {
progress = Math.min(100, progress + 25)
}
if (!(p.match(/.*[A-Z].*/))) {
msg += 'One Uppercase Letter. '
validation = validation && false
} else {
progress = Math.min(100, progress + 25)
}
if (!(p.match(/.*[0-9].*/))) {
msg += 'One Number. '
validation = validation && false
} else {
progress = Math.min(100, progress + 25)
}
if (!(p.match(/[$&+,:;=?@#|'<>.^*()%!_-]/))) {
msg += 'One special letter. '
validation = validation && false
} else {
progress = Math.min(100, progress + 25)
}
this.formUtil.passwordProgress = progress
// console.log('progress', progress);
// console.log('color', this.progressColor(this.formUtil.passwordProgress));
this.progressColorValue = this.progressColor(this.formUtil.passwordProgress)
this.formUtil.passwordValidateMsg = msg
// console.log('msg', msg, validation);
return validation
}
}
}

16
packages/nc-gui/pages/user/authentication/signup/_token.vue

@ -39,7 +39,7 @@
<v-text-field
v-model="form.email"
label="$t('signin.input_1')"
:label="$t('signin.enter_your_work_email')"
:rules="formRules.email"
required
/>
@ -47,7 +47,7 @@
<v-text-field
v-model="form.password"
name="input-10-2"
label="$t('signin.input_2')"
:label="$t('signin.enter_your_password')"
min="8"
:append-icon="formUtil.e3 ? 'visibility' : 'visibility_off'"
:rules="formRules.password"
@ -87,7 +87,7 @@
<br>
<br>
<p v-ge="['Already have an account ?','']" class="font-weight-light caption">
{{ $t('signup.message_2') }}
{{ $t('signup.already_ve_an_account') }}
<router-link to="/user/authentication/signin">
{{ $t('signin.title') }}
</router-link>
@ -230,6 +230,7 @@
// "./libs"
// );
import { isEmail } from '@/helpers'
import passwordValidateMixin from '@/pages/user/authentication/passwordValidateMixin'
// import VueRecaptcha from 'vue-recaptcha';
export default {
@ -237,6 +238,7 @@ export default {
// VueRecaptcha
},
directives: {},
mixins: [passwordValidateMixin],
layout: 'empty',
validate() {
return true
@ -354,7 +356,7 @@ export default {
return this.formUtil.progressColorValue
},
PasswordValidate(p) {
/* PasswordValidate(p) {
if (!p) {
this.passwordProgress = 0
this.passwordValidateMsg = 'Atleast 8 letters with one Uppercase, one number and one special letter'
@ -372,14 +374,14 @@ export default {
progress = Math.min(100, progress + 25)
}
if (!(p.match(/.*[A-Z].*/))) {
if (!(p.match(/.*[A-Z].*!/))) {
msg += 'One Uppercase Letter. '
validation = validation && false
} else {
progress = Math.min(100, progress + 25)
}
if (!(p.match(/.*[0-9].*/))) {
if (!(p.match(/.*[0-9].*!/))) {
msg += 'One Number. '
validation = validation && false
} else {
@ -403,7 +405,7 @@ export default {
// console.log('msg', msg, validation);
return validation
},
}, */
PlusCounter() {
this.$store.dispatch('ActPlusCounter')

53
packages/nc-gui/pages/user/authentication/signup/index.vue

@ -205,6 +205,7 @@
<script>
import { isEmail } from '@/helpers'
import passwordValidateMixin from '@/pages/user/authentication/passwordValidateMixin'
// import VueRecaptcha from 'vue-recaptcha';
export default {
@ -212,6 +213,7 @@ export default {
// VueRecaptcha
},
directives: {},
mixins: [passwordValidateMixin],
layout: 'empty',
validate({ params }) {
return true
@ -334,57 +336,6 @@ export default {
return this.formUtil.progressColorValue
},
PasswordValidate(p) {
if (!p) {
this.passwordProgress = 0
this.passwordValidateMsg = 'Atleast 8 letters with one Uppercase, one number and one special letter'
return false
}
let msg = ''
let validation = true
let progress = 0
if (!(p.length >= 8)) {
msg += 'Atleast 8 letters. '
validation = validation && false
} else {
progress = Math.min(100, progress + 25)
}
if (!(p.match(/.*[A-Z].*/))) {
msg += 'One Uppercase Letter. '
validation = validation && false
} else {
progress = Math.min(100, progress + 25)
}
if (!(p.match(/.*[0-9].*/))) {
msg += 'One Number. '
validation = validation && false
} else {
progress = Math.min(100, progress + 25)
}
if (!(p.match(/[$&+,:;=?@#|'<>.^*()%!-]/))) {
msg += 'One special letter. '
validation = validation && false
} else {
progress = Math.min(100, progress + 25)
}
this.formUtil.passwordProgress = progress
// console.log('progress', progress);
// console.log('color', this.progressColor(this.formUtil.passwordProgress));
this.progressColorValue = this.progressColor(this.formUtil.passwordProgress)
this.formUtil.passwordValidateMsg = msg
// console.log('msg', msg, validation);
return validation
},
PlusCounter() {
this.$store.dispatch('ActPlusCounter')
},

12
packages/nc-gui/pages/user/password/reset/index.vue

@ -52,10 +52,12 @@
<script>
import { isEmail } from '@/helpers'
import passwordValidateMixin from '@/pages/user/authentication/passwordValidateMixin'
export default {
directives: {},
components: {},
mixins: [passwordValidateMixin],
validate({ params }) {
// console.log('validate');
return true
@ -65,7 +67,7 @@ export default {
return {
resetSuccess: true,
passwordDetails: {
newPassword: null,
newPassword: '',
verifyPassword: null,
token: null
},
@ -122,7 +124,7 @@ export default {
this.$router.push('/')
}
},
PasswordValidate(p) {
/* PasswordValidate(p) {
if (!p) {
this.passwordProgress = 0
this.passwordValidateMsg = 'Atleast 8 letters with one Uppercase, one number and one special letter'
@ -140,14 +142,14 @@ export default {
progress = Math.min(100, progress + 25)
}
if (!(p.match(/.*[A-Z].*/))) {
if (!(p.match(/.*[A-Z].*!/))) {
msg += 'One Uppercase Letter. '
validation = validation && false
} else {
progress = Math.min(100, progress + 25)
}
if (!(p.match(/.*[0-9].*/))) {
if (!(p.match(/.*[0-9].*!/))) {
msg += 'One Number. '
validation = validation && false
} else {
@ -169,7 +171,7 @@ export default {
// console.log('msg', msg, validation);
return validation
},
}, */
PasswordValidate1(confirmPassword) {
if (confirmPassword) {
return this.passwordDetails.newPassword.startsWith(confirmPassword)

Loading…
Cancel
Save