diff --git a/packages/nc-gui/pages/user/authentication/passwordValidateMixin.js b/packages/nc-gui/pages/user/authentication/passwordValidateMixin.js new file mode 100644 index 0000000000..95bceeb79a --- /dev/null +++ b/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 + } + + } +} diff --git a/packages/nc-gui/pages/user/authentication/signup/_token.vue b/packages/nc-gui/pages/user/authentication/signup/_token.vue index 6c0cbaed2d..1c55b0a01a 100644 --- a/packages/nc-gui/pages/user/authentication/signup/_token.vue +++ b/packages/nc-gui/pages/user/authentication/signup/_token.vue @@ -39,7 +39,7 @@ @@ -47,7 +47,7 @@

- {{ $t('signup.message_2') }} + {{ $t('signup.already_ve_an_account') }} {{ $t('signin.title') }} @@ -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') diff --git a/packages/nc-gui/pages/user/authentication/signup/index.vue b/packages/nc-gui/pages/user/authentication/signup/index.vue index 8d8a67f2e5..8679b28284 100644 --- a/packages/nc-gui/pages/user/authentication/signup/index.vue +++ b/packages/nc-gui/pages/user/authentication/signup/index.vue @@ -205,6 +205,7 @@