Browse Source

fix(gui): Email validation

fix #267

Signed-off-by: Pranav C Balan <pranavxc@gmail.com>
pull/292/head
Pranav C Balan 4 years ago
parent
commit
797855d9df
  1. 3
      packages/nc-gui/components/auth/userManagement.vue
  2. 24
      packages/nc-gui/helpers/index.js
  3. 39
      packages/nc-gui/pages/user/authentication/signin.vue
  4. 3
      packages/nc-gui/pages/user/authentication/signup/index.vue

3
packages/nc-gui/components/auth/userManagement.vue

@ -453,6 +453,7 @@
import SetListCheckboxCell from "@/components/project/spreadsheet/editableCell/setListCheckboxCell"; import SetListCheckboxCell from "@/components/project/spreadsheet/editableCell/setListCheckboxCell";
import {enumColor as colors, enumColor} from "@/components/project/spreadsheet/helpers/colors"; import {enumColor as colors, enumColor} from "@/components/project/spreadsheet/helpers/colors";
import DlgLabelSubmitCancel from "@/components/utils/dlgLabelSubmitCancel"; import DlgLabelSubmitCancel from "@/components/utils/dlgLabelSubmitCancel";
import {isEmail} from "@/helpers";
export default { export default {
name: "user-management", name: "user-management",
@ -475,7 +476,7 @@ export default {
valid: null, valid: null,
emailRules: [ emailRules: [
v => !!v || 'E-mail is required', v => !!v || 'E-mail is required',
v => /^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i.test(v) || 'E-mail must be valid' v => isEmail(v) || 'E-mail must be valid'
], ],
userList: [] userList: []
}), }),

24
packages/nc-gui/helpers/index.js

@ -0,0 +1,24 @@
export const isEmail = v => /^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i.test(v)
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
*
* @author Naveen MR <oof1lab@gmail.com>
* @author Pranav C Balan <pranavxc@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

39
packages/nc-gui/pages/user/authentication/signin.vue

@ -64,7 +64,8 @@
<p class="accent--text text-right caption font-weight-light"> <p class="accent--text text-right caption font-weight-light">
<router-link to="/user/password/forgot">{{ <router-link to="/user/password/forgot">{{
$t('signin.forget_password') $t('signin.forget_password')
}}</router-link> }}
</router-link>
</p> </p>
<!-- <vue-recaptcha @verify="onNormalVerify" sitekey="6LfbcqMUAAAAAAb_2319UdF8m68JHSYVy_m4wPBx"--> <!-- <vue-recaptcha @verify="onNormalVerify" sitekey="6LfbcqMUAAAAAAb_2319UdF8m68JHSYVy_m4wPBx"-->
@ -87,9 +88,9 @@
<b>Sign In</b> <b>Sign In</b>
</v-btn> </v-btn>
<br /> <br/>
<br /> <br/>
<br /> <br/>
<!-- Don't have an account ? --> <!-- Don't have an account ? -->
<p class="caption font-weight-light"> <p class="caption font-weight-light">
{{ $t('signin.footer_text_1') }} {{ $t('signin.footer_text_1') }}
@ -199,7 +200,7 @@
</v-form> </v-form>
<template v-else> <template v-else>
<br /> <br/>
<v-alert type="warning" outlined icon="mdi-alert"> <v-alert type="warning" outlined icon="mdi-alert">
<!-- <v-icon color="warning">mdi-alert</v-icon>--> <!-- <v-icon color="warning">mdi-alert</v-icon>-->
Authentication not configured in configuration Authentication not configured in configuration
@ -209,7 +210,7 @@
</v-col> </v-col>
</v-row> </v-row>
<br /> <br/>
</v-col> </v-col>
</v-row> </v-row>
</v-container> </v-container>
@ -221,8 +222,9 @@ import Vue from 'vue';
// const {shell} = require("electron").remote.require( // const {shell} = require("electron").remote.require(
// "./libs" // "./libs"
// ); // );
import { mapGetters, mapActions } from 'vuex'; import {mapGetters, mapActions} from 'vuex';
import { VueReCaptcha } from 'vue-recaptcha-v3'; import {VueReCaptcha} from 'vue-recaptcha-v3';
import {isEmail} from "@/helpers";
// import VueRecaptcha from 'vue-recaptcha'; // import VueRecaptcha from 'vue-recaptcha';
export default { export default {
@ -243,8 +245,7 @@ export default {
// E-mail is required // E-mail is required
(v) => !!v || this.$t('signin.form.rules.email_1'), (v) => !!v || this.$t('signin.form.rules.email_1'),
// E-mail must be valid // E-mail must be valid
(v) => (v) => isEmail(v) ||
/^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/.test(v) ||
this.$t('signin.form.rules.email_2'), this.$t('signin.form.rules.email_2'),
], ],
password: [ password: [
@ -301,7 +302,7 @@ export default {
// await this.$recaptchaLoaded() // await this.$recaptchaLoaded()
// const recaptchaToken = await this.$recaptcha('login') // const recaptchaToken = await this.$recaptcha('login')
err = await this.$store.dispatch('users/ActSignIn', { ...this.form }); //, recaptchaToken}); err = await this.$store.dispatch('users/ActSignIn', {...this.form}); //, recaptchaToken});
if (err) { if (err) {
this.formUtil.formErr = true; this.formUtil.formErr = true;
this.formUtil.formErrMsg = err.data.msg; this.formUtil.formErrMsg = err.data.msg;
@ -364,20 +365,24 @@ export default {
); );
}, },
}, },
beforeCreated() {}, beforeCreated() {
},
async created() { async created() {
// this.type = (await this.$store.dispatch('users/ActGetAuthType')).type; // this.type = (await this.$store.dispatch('users/ActGetAuthType')).type;
if (this.$route.query && this.$route.query.error) { if (this.$route.query && this.$route.query.error) {
this.$nextTick(() => this.$nextTick(() =>
this.$toast.error(this.$route.query.error).goAway(5000) this.$toast.error(this.$route.query.error).goAway(5000)
); );
this.$router.replace({ path: '/user/authentication/signin' }); this.$router.replace({path: '/user/authentication/signin'});
} }
}, },
mounted() {}, mounted() {
beforeDestroy() {}, },
destroy() {}, beforeDestroy() {
validate({ params }) { },
destroy() {
},
validate({params}) {
return true; return true;
}, },
head() { head() {

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

@ -205,6 +205,7 @@
// "./libs" // "./libs"
// ); // );
import {mapGetters, mapActions} from 'vuex' import {mapGetters, mapActions} from 'vuex'
import {isEmail} from "@/helpers";
// import VueRecaptcha from 'vue-recaptcha'; // import VueRecaptcha from 'vue-recaptcha';
export default { export default {
@ -229,7 +230,7 @@ export default {
email: [ email: [
v => !!v || 'E-mail is required', v => !!v || 'E-mail is required',
// ref : https://stackoverflow.com/a/46181 // ref : https://stackoverflow.com/a/46181
v => /^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i.test(v) || 'E-mail must be valid' v => isEmail(v) || 'E-mail must be valid'
], ],
password: [ password: [
v => (this.PasswordValidate(v)) || this.passwordValidateMsg v => (this.PasswordValidate(v)) || this.passwordValidateMsg

Loading…
Cancel
Save