summaryrefslogtreecommitdiff
path: root/StoneIsland/www/js
diff options
context:
space:
mode:
Diffstat (limited to 'StoneIsland/www/js')
-rw-r--r--StoneIsland/www/js/lib/account/ProfileView.js5
-rw-r--r--StoneIsland/www/js/lib/auth/SignupView.js8
-rw-r--r--StoneIsland/www/js/sdk/auth.js23
-rw-r--r--StoneIsland/www/js/vendor/view/serializable.js2
4 files changed, 23 insertions, 15 deletions
diff --git a/StoneIsland/www/js/lib/account/ProfileView.js b/StoneIsland/www/js/lib/account/ProfileView.js
index f03572dc..3c37c835 100644
--- a/StoneIsland/www/js/lib/account/ProfileView.js
+++ b/StoneIsland/www/js/lib/account/ProfileView.js
@@ -23,8 +23,9 @@ var ProfileView = FormView.extend({
},
validate_fields: function(errors){
- if (data.Password && ! data.Password2) { errors.push("Password2", "Please enter your new password.") }
- if (data.Password && data.Password.length < 7) { errors.push("Password", "Password must be 7 characters or more.") }
+ if (! data.CurrentPassword && data.NewPassword) { 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.") }
},
success: function(data){
diff --git a/StoneIsland/www/js/lib/auth/SignupView.js b/StoneIsland/www/js/lib/auth/SignupView.js
index 6ca1ccba..3ad84cc9 100644
--- a/StoneIsland/www/js/lib/auth/SignupView.js
+++ b/StoneIsland/www/js/lib/auth/SignupView.js
@@ -36,11 +36,13 @@ var SignupView = FormView.extend({
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 !== data.ConfirmEmail) { errors.push("ConfirmEmail", "Email addresses don't match.") }
+ 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" }
- if (! data.DataProfiling) { data.DataProfiling = "false" }
},
privacy_link: function(){
+ // rewrite app.privacy instance temporarily
app.privacy.back = function(){
app.router.go("account/signup")
}
@@ -51,14 +53,16 @@ var SignupView = FormView.extend({
},
success: function(data){
+ console.log('success', data)
app.account.logged_in()
},
error: function(data){
+ console.log('error', data)
},
cancel: function(){
- auth.defer_add_to_cart = null
+ auth.deferred_product = null
},
/*
diff --git a/StoneIsland/www/js/sdk/auth.js b/StoneIsland/www/js/sdk/auth.js
index c1546532..fe7acc5c 100644
--- a/StoneIsland/www/js/sdk/auth.js
+++ b/StoneIsland/www/js/sdk/auth.js
@@ -41,11 +41,13 @@ var auth = sdk.auth = (function(){
cb && cb()
}
auth.get_user = function(cb){
- access_token = localStorage.getItem("yoox.access_token") || ""
- user_id = localStorage.getItem("yoox.user_id") || -1
+ auth.access_token = localStorage.getItem("yoox.access_token") || ""
+ auth.user_id = localStorage.getItem("yoox.user_id") || -1
cb && cb()
}
auth.clear_user = function(cb){
+ auth.access_token = ""
+ auth.user_id = -1
localStorage.removeItem("yoox.access_token")
localStorage.removeItem("yoox.user_id")
cb && cb()
@@ -57,18 +59,21 @@ var auth = sdk.auth = (function(){
cb && cb()
}
auth.get_cart = function(cb){
- cart.token = localStorage.getItem("yoox.cart_token") || ""
- cart.id = localStorage.getItem("yoox.cart_id") || -1
+ sdk.cart.token = localStorage.getItem("yoox.cart_token") || ""
+ sdk.cart.id = localStorage.getItem("yoox.cart_id") || -1
cb && cb()
}
auth.clear_cart = function(cb){
+ sdk.cart.token = ""
+ sdk.cart.id = -1
localStorage.removeItem("yoox.cart_token")
localStorage.removeItem("yoox.cart_id")
cb && cb()
}
auth.create_cart = function(cb){
- cart.initialize().done(function(){
- cart.set_user().done(function(){
+ if (auth.has_cart) { return cb() }
+ sdk.cart.initialize().done(function(){
+ sdk.cart.set_user().done(function(){
auth.set_cart(sdk.cart.id, sdk.cart.token, function(){
cb && cb()
})
@@ -79,10 +84,8 @@ var auth = sdk.auth = (function(){
// auth.deferred_product
}
auth.log_out = function(){
- auth.access_token = ""
- auth.user_id = -1
- cart.token = ""
- cart.id = -1
+ auth.clear_user()
+ auth.clear_cart()
auth.view_logged_out()
}
auth.logged_in = function(){
diff --git a/StoneIsland/www/js/vendor/view/serializable.js b/StoneIsland/www/js/vendor/view/serializable.js
index 80218266..db996f23 100644
--- a/StoneIsland/www/js/vendor/view/serializable.js
+++ b/StoneIsland/www/js/vendor/view/serializable.js
@@ -79,4 +79,4 @@ var SerializableView = View.extend({
})
-var FormView = View.extend(SerializableView).extend(ScrollableView)
+var FormView = View.extend(SerializableView.prototype).extend(ScrollableView.prototype)