summaryrefslogtreecommitdiff
path: root/StoneIsland/www/js/sdk
diff options
context:
space:
mode:
Diffstat (limited to 'StoneIsland/www/js/sdk')
-rw-r--r--StoneIsland/www/js/sdk/account.js49
-rw-r--r--StoneIsland/www/js/sdk/auth.js10
2 files changed, 57 insertions, 2 deletions
diff --git a/StoneIsland/www/js/sdk/account.js b/StoneIsland/www/js/sdk/account.js
index 3b48b0d9..fe5f03cd 100644
--- a/StoneIsland/www/js/sdk/account.js
+++ b/StoneIsland/www/js/sdk/account.js
@@ -47,6 +47,55 @@ sdk.account = (function(){
})
}
+ account.checkin = function(opt){
+ return $.ajax({
+ method: "GET",
+ url: sdk.path("Account.API/1.5", "users/" + auth.user_id + ".json"),
+ headers: {
+ "x-yoox-appname": auth.appname,
+ "x-yoox-account-token": auth.access_token,
+ },
+ data: "{}",
+ success: function(data){
+ auth.user = data.User
+ opt.success(data)
+ },
+ error: opt.error,
+ })
+ }
+
+ account.update = function(opt){
+ return $.ajax({
+ method: "PUT",
+ url: sdk.path("Account.API/1.5", "users/" + auth.user_id + ".json"),
+ headers: {
+ "x-yoox-appname": auth.appname,
+ "x-yoox-account-token": auth.access_token,
+ },
+ data: JSON.stringify( opt.data ),
+ success: function(data){
+ opt.success(data)
+ },
+ error: opt.error,
+ })
+ }
+
+ account.update_mail_and_password = function(opt){
+ return $.ajax({
+ method: "PUT",
+ url: sdk.path("Account.API/1.5", "auth/" + auth.user_id + ".json"),
+ headers: {
+ "x-yoox-appname": auth.appname,
+ "x-yoox-account-token": auth.access_token,
+ },
+ data: JSON.stringify( opt.data ),
+ success: function(data){
+ opt.success(data)
+ },
+ error: opt.error,
+ })
+ }
+
return account
})()
diff --git a/StoneIsland/www/js/sdk/auth.js b/StoneIsland/www/js/sdk/auth.js
index 1fbf48ec..8a72dd46 100644
--- a/StoneIsland/www/js/sdk/auth.js
+++ b/StoneIsland/www/js/sdk/auth.js
@@ -26,11 +26,17 @@ var auth = sdk.auth = (function(){
auth.init = function(fn){
console.log("AUTH INIT")
auth.get_user(function(){
- console.log("cool")
if (auth.logged_in()) {
+ sdk.account.checkin({
+ success: function(data){
+ fn && fn( auth.logged_in() )
+ }
+ })
auth.get_cart()
}
- fn && fn( auth.logged_in() )
+ else {
+ fn && fn( auth.logged_in() )
+ }
})
}