summaryrefslogtreecommitdiff
path: root/StoneIsland/platforms/ios/www/js/lib/auth
diff options
context:
space:
mode:
Diffstat (limited to 'StoneIsland/platforms/ios/www/js/lib/auth')
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/auth/LoginView.js53
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/auth/LogoutView.js15
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/auth/SignupView.js103
3 files changed, 171 insertions, 0 deletions
diff --git a/StoneIsland/platforms/ios/www/js/lib/auth/LoginView.js b/StoneIsland/platforms/ios/www/js/lib/auth/LoginView.js
new file mode 100644
index 00000000..1f7438cc
--- /dev/null
+++ b/StoneIsland/platforms/ios/www/js/lib/auth/LoginView.js
@@ -0,0 +1,53 @@
+var LoginView = FormView.extend({
+
+ el: "#login",
+
+ action: sdk.account.login,
+
+ events: {
+ "click .newuser": "new_user",
+ "submit form": "save",
+ },
+
+ initialize: function(){
+ this.$form = this.$("form")
+ this.$msg = this.$(".msg")
+ this.scroller = new IScroll('#login', app.iscroll_options)
+ },
+
+ show: function(){
+ if (auth.logged_in()) {
+ app.router.go("intro")
+ return
+ }
+ var msg = "* Your personal and payment<br>information will always remain private"
+ app.footer.show("SUBMIT", "CANCEL")
+ this.$form.get(0).reset()
+ this.$msg.html(msg)
+ document.body.className = "login"
+ },
+
+ new_user: function(){
+ app.router.go("account/signup")
+ },
+
+ validate_presence: {
+ "Email": "Please enter a valid email address.",
+ "Password": "Please enter your password.",
+ },
+
+ success: function(data){
+ // console.log(data)
+ app.account.logged_in(function(){ app.router.go("store") })
+ },
+
+ error: function(data){
+ this.$msg.html("There was an error logging you in. Bad password?")
+ this.$msg.addClass('alert-notice')
+ },
+
+ cancel: function(){
+ auth.deferred_product = null
+ },
+
+})
diff --git a/StoneIsland/platforms/ios/www/js/lib/auth/LogoutView.js b/StoneIsland/platforms/ios/www/js/lib/auth/LogoutView.js
new file mode 100644
index 00000000..735c0242
--- /dev/null
+++ b/StoneIsland/platforms/ios/www/js/lib/auth/LogoutView.js
@@ -0,0 +1,15 @@
+var LogoutView = View.extend({
+
+ el: "#logout",
+
+ events: {
+ },
+
+ show: function(){
+ document.body.className = "logout"
+ app.footer.hide()
+ app.account.logged_out()
+ auth.clear_user()
+ },
+
+}) \ No newline at end of file
diff --git a/StoneIsland/platforms/ios/www/js/lib/auth/SignupView.js b/StoneIsland/platforms/ios/www/js/lib/auth/SignupView.js
new file mode 100644
index 00000000..7f894c3c
--- /dev/null
+++ b/StoneIsland/platforms/ios/www/js/lib/auth/SignupView.js
@@ -0,0 +1,103 @@
+var SignupView = FormView.extend({
+
+ el: "#signup",
+
+ action: sdk.account.signup,
+ last_data: null,
+
+ test_data: {
+ "Email": "testit.account" + Math.floor(Math.random() * 10000000) + "@yoox.com",
+ "Password": "TestPassword",
+ "Password2": "TestPassword",
+ "Gender": "U",
+ "Name": "TestName",
+ "Surname": "TestSurname",
+ "BirthDay": "1978-11-12",
+ "DataProfiling": true,
+ "DataProfiling2": true,
+ },
+
+ events: {
+ "click .privacy-msg": "privacy_link",
+ "submit form": "save",
+ },
+
+ initialize: function(){
+ this.$form = this.$("form")
+ this.$msg = this.$(".msg")
+ this.scroller = new IScroll('#signup', app.iscroll_options)
+ },
+
+ show: function(){
+ if (auth.logged_in()) {
+ app.router.go("intro")
+ return
+ }
+ var msg = "* Your personal and payment<br>information will always remain private"
+ app.footer.show("SUBMIT", "CANCEL")
+ this.$form.get(0).reset()
+ this.$msg.html(msg)
+ document.body.className = "signup"
+
+ this.preload()
+ },
+
+ validate_presence: {
+ "Name": "Please enter your first name.",
+ "Surname": "Please enter your last name.",
+ "Email": "Please enter a valid email address.",
+ "ConfirmEmail": "Please enter a valid email address.",
+ "Password": "Please enter your password.",
+ "Password2": "Please enter your password again.",
+ "DataProfiling": "You must agree to data profiling.",
+ },
+
+ validate_fields: function(data, errors){
+ if (data.Password.length < 7) { errors.push([ "Password", "Password must be 7 characters or more." ]) }
+ if (data.Password !== data.Password2) { errors.push([ "Password2", "Passwords don't match." ]) }
+ if (! data.Email.match("@")) { errors.push([ "Email", "Email address is not valid." ]) }
+ if (data.Email.toLowerCase() !== data.ConfirmEmail.toLowerCase()) { errors.push([ "ConfirmEmail", "Email addresses don't match." ]) }
+ if (data.Gender === "NONE") { errors.push([ "Gender", "Please supply your gender." ]) }
+ if (data.DataProfiling !== "true") { errors.push([ "DataProfiling", "You must consent to use this service." ]) }
+ if (data.DataProfiling2 !== "true") { errors.push([ "DataProfiling2", "You must consent to use this service." ]) }
+ if (! data.YooxLetter) { data.YooxLetter = false }
+
+ delete data.DataProfiling2
+ delete data.ConfirmEmail
+
+ data.BirthDay += "T00:00:00Z"
+
+ this.last_data = data
+ console.log(data)
+ },
+
+ privacy_link: function(){
+ // rewrite app.privacy instance temporarily
+ app.privacy.back = function(){
+ app.router.go("account/signup")
+ }
+ app.privacy.hide = function(){
+ app.privacy.back = app.privacy.hide = null
+ }
+ app.router.go("page/privacy")
+ },
+
+ success: function(data){
+ console.log('success', data)
+ auth.user = auth.user || {}
+ auth.user.Name = this.last_data.Name
+ auth.user.Surname = this.last_data.Surname
+ auth.user.Email = this.last_data.Email
+ auth.user.BirthDay = this.last_data.BirthDay
+ app.account.logged_in(function(){ app.router.go("store") })
+ },
+
+ error: function(data){
+ console.log('error', data)
+ },
+
+ cancel: function(){
+ auth.deferred_product = null
+ },
+
+}) \ No newline at end of file