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. 43
      packages/nc-gui/pages/user/authentication/signin.vue
  4. 5
      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 {enumColor as colors, enumColor} from "@/components/project/spreadsheet/helpers/colors";
import DlgLabelSubmitCancel from "@/components/utils/dlgLabelSubmitCancel";
import {isEmail} from "@/helpers";
export default {
name: "user-management",
@ -475,7 +476,7 @@ export default {
valid: null,
emailRules: [
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: []
}),

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/>.
*
*/

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

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

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

@ -205,6 +205,7 @@
// "./libs"
// );
import {mapGetters, mapActions} from 'vuex'
import {isEmail} from "@/helpers";
// import VueRecaptcha from 'vue-recaptcha';
export default {
@ -229,7 +230,7 @@ export default {
email: [
v => !!v || 'E-mail is required',
// 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: [
v => (this.PasswordValidate(v)) || this.passwordValidateMsg
@ -340,7 +341,7 @@ export default {
async MtdOnSignup(e) {
e.preventDefault();
this.signUpButtonLoading = true;
if (this.type === 'jwt') {

Loading…
Cancel
Save