Backend support for registration validation.

terms and conditions.
Issues #3 #4
This commit is contained in:
Sagi Dayan 2020-02-15 13:07:23 -05:00
parent b75ac5aa97
commit 1f49924963
8 changed files with 30 additions and 3083 deletions

View file

@ -1,17 +1,15 @@
'use strict'
class IndexController {
async index({auth, view}){
try{
await auth.check();
return view.render('home');
}catch(e){
const bgIndex = Math.ceil((Math.random()*10)%5);
console.log(bgIndex)
return view.render('landing', {bgIndex});
}
async index({auth, view}) {
try {
await auth.check();
return view.render('home');
} catch (e) {
const bgIndex = Math.ceil((Math.random() * 10) % 5);
return view.render('landing', {bgIndex});
}
}
}
module.exports = IndexController

View file

@ -1,21 +1,20 @@
'use strict'
class Register {
get rules () {
get rules() {
return {
name: 'required|min:1',
email: 'required|email|unique:users',
password: 'required|string|min:6',
// validation rules
name: 'required|min:1', email: 'required|email|unique:users',
password: 'required|string|min:6', terms: 'required|string|min:1',
}
}
get messages() {
return {
'name.min': 'Must provide a name',
'email.unique': 'This email is already taken',
'required': 'This is required',
'email.unique': 'This email is already taken',
'password.min': 'Password must be at least 6 chars long'
'email.unique': 'This email is already taken',
'required': 'This is required',
'email.unique': 'This email is already taken',
'password.min': 'Password must be at least 6 chars long',
'terms.min': 'Must confirm terms and conditions'
}
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -17,6 +17,7 @@ document.addEventListener("DOMContentLoaded", () => {
function validateForm(): void {
isFormValid = form.checkValidity() && isPassMatch && terms.checked;
submit.disabled = !isFormValid;
terms.value = terms.checked ? "on" : "";
}
validateForm();

View file

@ -80,9 +80,10 @@
<div class="field is-grouped">
<div class="control">
<label class="checkbox">
<input type="checkbox" id="chk-register-terms">
<input type="checkbox" id="chk-register-terms" name="terms">
I agree to the <a href="#">terms and conditions</a>
</label>
<p class="help is-danger">{{ getErrorFor('terms') ? getErrorFor('terms') : '' }}</p>
<div class="control">
<button id="btn-register-submit" class="button is-link" disabled="true">Submit</button>
</div>

View file

@ -65,9 +65,10 @@ Seepur| Register
<div class="field">
<div class="control">
<label class="checkbox">
<input type="checkbox" id="chk-register-terms">
<input type="checkbox" id="chk-register-terms" name="terms">
I agree to the <a href="#">terms and conditions</a>
</label>
<p class="help is-danger">{{ getErrorFor('terms') ? getErrorFor('terms') : '' }}</p>
</div>
</div>