Browse Source

fix(gui): Email validation

fix #267

Signed-off-by: Pranav C Balan <pranavxc@gmail.com>
pull/292/head
Pranav C Balan 3 years ago
parent
commit
797855d9df
  1. 3
      packages/nc-gui/components/auth/userManagement.vue
  2. 24
      packages/nc-gui/helpers/index.js
  3. 19
      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 {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/>.
*
*/

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

@ -64,7 +64,8 @@
<p class="accent--text text-right caption font-weight-light">
<router-link to="/user/password/forgot">{{
$t('signin.forget_password')
}}</router-link>
}}
</router-link>
</p>
<!-- <vue-recaptcha @verify="onNormalVerify" sitekey="6LfbcqMUAAAAAAb_2319UdF8m68JHSYVy_m4wPBx"-->
@ -223,6 +224,7 @@ import Vue from 'vue';
// );
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: [
@ -364,7 +365,8 @@ export default {
);
},
},
beforeCreated() {},
beforeCreated() {
},
async created() {
// this.type = (await this.$store.dispatch('users/ActGetAuthType')).type;
if (this.$route.query && this.$route.query.error) {
@ -374,9 +376,12 @@ export default {
this.$router.replace({path: '/user/authentication/signin'});
}
},
mounted() {},
beforeDestroy() {},
destroy() {},
mounted() {
},
beforeDestroy() {
},
destroy() {
},
validate({params}) {
return true;
},

3
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

Loading…
Cancel
Save