diff options
author | Camil Staps | 2015-05-13 08:15:31 +0200 |
---|---|---|
committer | Camil Staps | 2015-05-13 08:15:31 +0200 |
commit | 3252fb165b74a9daf2ce27ac05b6c5a1c22018d4 (patch) | |
tree | bdc682dd63d557c089765bf6030b5b19cbe7cc4d | |
parent | Save token information in cookies (diff) |
Save user's email in cookie
-rw-r--r-- | src/js/Botleagues.js | 6 | ||||
-rw-r--r-- | src/js/BotleaguesCallback.js | 1 | ||||
-rw-r--r-- | src/js/BotleaguesFrontend.js | 2 |
3 files changed, 7 insertions, 2 deletions
diff --git a/src/js/Botleagues.js b/src/js/Botleagues.js index c219a3d..f11c995 100644 --- a/src/js/Botleagues.js +++ b/src/js/Botleagues.js @@ -29,13 +29,15 @@ Botleagues.redirect = function(user_options) { window.location = Botleagues.url + '/' + user_options['endpoint']; }; -Botleagues.login = function(username, password) { +Botleagues.login = function(email, password) { Botleagues.request({ endpoint: 'user_token', method: 'POST', callback: BotleaguesCallback.login, headers: { - 'Authorization': 'Basic ' + btoa(username + ':' + password) + 'Authorization': 'Basic ' + btoa(email + ':' + password) } }); + + $.cookie(BotleaguesFrontend.cookie_login_email, email); };
\ No newline at end of file diff --git a/src/js/BotleaguesCallback.js b/src/js/BotleaguesCallback.js index ce91d50..3e7e512 100644 --- a/src/js/BotleaguesCallback.js +++ b/src/js/BotleaguesCallback.js @@ -44,5 +44,6 @@ BotleaguesCallback.login = function(data) { BotleaguesFrontend.error({ message: data.error ? data.error : "Could not login." }); + $.removeCookie(BotleaguesFrontend.cookie_login_email); } };
\ No newline at end of file diff --git a/src/js/BotleaguesFrontend.js b/src/js/BotleaguesFrontend.js index be80f31..b365743 100644 --- a/src/js/BotleaguesFrontend.js +++ b/src/js/BotleaguesFrontend.js @@ -1,5 +1,7 @@ function BotleaguesFrontend(){} +$.cookie.json = true; +BotleaguesFrontend.cookie_login_email = 'botleagues_login_email'; BotleaguesFrontend.cookie_login_user_id = 'botleagues_login_user_id'; BotleaguesFrontend.cookie_login_token = 'botleagues_login_token'; BotleaguesFrontend.cookie_login_valid_till = 'botleagues_login_valid_till'; |