|
@@ -17,6 +17,7 @@
|
|
|
import RegisterModal from './components/Modals/Register.vue';
|
|
|
import auth from './auth';
|
|
|
import io from './io';
|
|
|
+ import validation from './validation';
|
|
|
|
|
|
export default {
|
|
|
replace: false,
|
|
@@ -87,6 +88,20 @@
|
|
|
'register': function (recaptchaId) {
|
|
|
let { register: { email, username, password } } = this;
|
|
|
let _this = this;
|
|
|
+ if (!email || !username || !password) return Toast.methods.addToast('Please fill in all fields', 8000);
|
|
|
+
|
|
|
+
|
|
|
+ if (!validation.isLength(email, 3, 254)) return Toast.methods.addToast('Email must have between 3 and 254 characters.', 8000);
|
|
|
+ if (email.indexOf('@') !== email.lastIndexOf('@') || !validation.regex.emailSimple.test(email)) return Toast.methods.addToast('Invalid email format.', 8000);
|
|
|
+
|
|
|
+
|
|
|
+ if (!validation.isLength(username, 2, 32)) return Toast.methods.addToast('Username must have between 2 and 32 characters.', 8000);
|
|
|
+ if (!validation.regex.azAZ09_.test(username)) return Toast.methods.addToast('Invalid username format. Allowed characters: a-z, A-Z, 0-9 and _.', 8000);
|
|
|
+
|
|
|
+
|
|
|
+ if (!validation.isLength(password, 6, 200)) return Toast.methods.addToast('Password must have between 6 and 200 characters.', 8000);
|
|
|
+ if (!validation.regex.password.test(password)) return Toast.methods.addToast('Invalid password format. Must have one lowercase letter, one uppercase letter, one number and one special character.', 8000);
|
|
|
+
|
|
|
this.socket.emit('users.register', username, email, password, grecaptcha.getResponse(recaptchaId), result => {
|
|
|
if (result.status === 'success') {
|
|
|
Toast.methods.addToast(`You have successfully registered.`, 4000);
|