Backend support for registration validation.
terms and conditions. Issues #3 #4
This commit is contained in:
parent
b75ac5aa97
commit
1f49924963
8 changed files with 30 additions and 3083 deletions
|
@ -1,15 +1,13 @@
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
class IndexController {
|
class IndexController {
|
||||||
async index({auth, view}){
|
async index({auth, view}) {
|
||||||
try{
|
try {
|
||||||
await auth.check();
|
await auth.check();
|
||||||
return view.render('home');
|
return view.render('home');
|
||||||
}catch(e){
|
} catch (e) {
|
||||||
const bgIndex = Math.ceil((Math.random()*10)%5);
|
const bgIndex = Math.ceil((Math.random() * 10) % 5);
|
||||||
console.log(bgIndex)
|
|
||||||
return view.render('landing', {bgIndex});
|
return view.render('landing', {bgIndex});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
class Register {
|
class Register {
|
||||||
get rules () {
|
get rules() {
|
||||||
return {
|
return {
|
||||||
name: 'required|min:1',
|
name: 'required|min:1', email: 'required|email|unique:users',
|
||||||
email: 'required|email|unique:users',
|
password: 'required|string|min:6', terms: 'required|string|min:1',
|
||||||
password: 'required|string|min:6',
|
|
||||||
// validation rules
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
get messages() {
|
get messages() {
|
||||||
|
@ -15,7 +13,8 @@ class Register {
|
||||||
'email.unique': 'This email is already taken',
|
'email.unique': 'This email is already taken',
|
||||||
'required': 'This is required',
|
'required': 'This is required',
|
||||||
'email.unique': 'This email is already taken',
|
'email.unique': 'This email is already taken',
|
||||||
'password.min': 'Password must be at least 6 chars long'
|
'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
|
@ -17,6 +17,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||||
function validateForm(): void {
|
function validateForm(): void {
|
||||||
isFormValid = form.checkValidity() && isPassMatch && terms.checked;
|
isFormValid = form.checkValidity() && isPassMatch && terms.checked;
|
||||||
submit.disabled = !isFormValid;
|
submit.disabled = !isFormValid;
|
||||||
|
terms.value = terms.checked ? "on" : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
validateForm();
|
validateForm();
|
||||||
|
|
|
@ -80,9 +80,10 @@
|
||||||
<div class="field is-grouped">
|
<div class="field is-grouped">
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<label class="checkbox">
|
<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>
|
I agree to the <a href="#">terms and conditions</a>
|
||||||
</label>
|
</label>
|
||||||
|
<p class="help is-danger">{{ getErrorFor('terms') ? getErrorFor('terms') : '' }}</p>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<button id="btn-register-submit" class="button is-link" disabled="true">Submit</button>
|
<button id="btn-register-submit" class="button is-link" disabled="true">Submit</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -65,9 +65,10 @@ Seepur| Register
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<label class="checkbox">
|
<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>
|
I agree to the <a href="#">terms and conditions</a>
|
||||||
</label>
|
</label>
|
||||||
|
<p class="help is-danger">{{ getErrorFor('terms') ? getErrorFor('terms') : '' }}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Reference in a new issue