diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-09-28 19:22:55 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-09-28 19:22:55 -0400 |
| commit | 8bf5b7f2e3be707523d202066f0c14dcd172f46a (patch) | |
| tree | 8ea0564be09bd416ee05fc0f74e80a18d52a66f1 /StoneIsland/platforms/ios/www/js/sdk/account.js | |
| parent | ef694896c0d53f5dbd49377e5b2382368846ad65 (diff) | |
build
Diffstat (limited to 'StoneIsland/platforms/ios/www/js/sdk/account.js')
| -rw-r--r-- | StoneIsland/platforms/ios/www/js/sdk/account.js | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/StoneIsland/platforms/ios/www/js/sdk/account.js b/StoneIsland/platforms/ios/www/js/sdk/account.js new file mode 100644 index 00000000..a1498e76 --- /dev/null +++ b/StoneIsland/platforms/ios/www/js/sdk/account.js @@ -0,0 +1,54 @@ +sdk.account = (function(){ + + var user_id, access_token + + // https://gist.github.com/fanfare/d18498e7fa25acbd4486 + var account = {} + account.signup = function(opt){ + $.ajax({ + method: "POST", + url: sdk.path("Account.API/1.5", "users.json"), + headers: { + "x-yoox-appname": auth.appname, + "x-yoox-api-key": auth.apikey, + }, + data: opt.data, + success: function(data){ + console.log(data) + user_id = data['UserAccount']['UserId'] + access_token = data['UserAccount']['AccessToken'] + + auth.set_user(user_id, access_token, name) + + opt.success(data) + }, + error: opt.error, + }) + } + + account.login = function(opt){ + $.ajax({ + method: "POST", + url: sdk.path("Account.API/1.5", "authfull.json"), + headers: { + "x-yoox-appname": auth.appname, + "x-yoox-account-token": auth.access_token, + }, + data: opt.data, + success: function(data){ + console.log(data) + auth.user_id = data['UserAccount']['UserId'] + auth.access_token = data['UserAccount']['AccessToken'] + + // why bother? + // auth.set_user(user_id, access_token, name) + + opt.success(data) + }, + error: opt.error, + }) + } + + return account + +})() |
