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

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

@ -205,6 +205,7 @@
<script> <script>
import { isEmail } from '@/helpers' import { isEmail } from '@/helpers'
import passwordValidateMixin from '@/pages/user/authentication/passwordValidateMixin'
// import VueRecaptcha from 'vue-recaptcha'; // import VueRecaptcha from 'vue-recaptcha';
export default { export default {
@ -212,6 +213,7 @@ export default {
// VueRecaptcha // VueRecaptcha
}, },
directives: {}, directives: {},
mixins: [passwordValidateMixin],
layout: 'empty', layout: 'empty',
validate({ params }) { validate({ params }) {
return true return true
@ -334,57 +336,6 @@ export default {
return this.formUtil.progressColorValue 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() { PlusCounter() {
this.$store.dispatch('ActPlusCounter') this.$store.dispatch('ActPlusCounter')
}, },

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

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

Loading…
Cancel
Save