From ec92c9432cf452badb6cca2c41e41d0546006692 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 24 Jul 2018 18:18:50 +0200 Subject: many updates. consent modal --- StoneIsland/www/js/lib/account/ProfileView.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'StoneIsland/www/js/lib/account/ProfileView.js') diff --git a/StoneIsland/www/js/lib/account/ProfileView.js b/StoneIsland/www/js/lib/account/ProfileView.js index ee39374b..a4e06791 100755 --- a/StoneIsland/www/js/lib/account/ProfileView.js +++ b/StoneIsland/www/js/lib/account/ProfileView.js @@ -21,6 +21,8 @@ var ProfileView = FormView.extend({ app.closed.setMessage("PLEASE GO ONLINE TO
EDIT YOUR PROFILE.", "") return } + if (! auth.user) return + app.account.consent.check() app.footer.show("SAVE") document.body.className = "profile" if (auth.user.BirthDay.match(/T/)) { @@ -47,6 +49,7 @@ var ProfileView = FormView.extend({ "Name": "Please enter your first name.", "Surname": "Please enter your last name.", "Email": "Please enter a valid email address.", + "BirthDay": "Please your birthday.", }, validate_fields: function(data, errors){ @@ -54,7 +57,14 @@ var ProfileView = FormView.extend({ if (! data.CurrentPassword && (data.NewPassword || data.Email !== auth.user.Email)) { errors.push([ "CurrentPassword", "Please enter your current password." ]) } if (data.CurrentPassword && ! data.NewPassword) { errors.push([ "NewPassword", "Please enter your new password." ]) } if (data.NewPassword && data.NewPassword.length < 7) { errors.push([ "CurrentPassword", "New password must be 7 characters or more." ]) } - if (! data.Birthday) data.BirthDay = '1900-01-01' + var now = new Date () + var year = now.getFullYear() + if (! data.BirthDay) data.BirthDay = year + '-01-01' + if (data.BirthDay.split('-')[0] || '2018') + var birthday = new Date (data.BirthDay) + if (isNaN(birthday) || (now - birthday) / (365*24*60*60*1000) < 18) { + errors.push(['BirthDay', 'You must be 18 or older to use the Stone Island app.']) + } // if (data.Gender === "NONE") { errors.push([ "Gender", "Please supply your gender." ]) } }, -- cgit v1.2.3-70-g09d2