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,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
|
||||
|
|
|
@ -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
|
@ -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();
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
Reference in a new issue