diff options
author | Azul <azul@leap.se> | 2013-09-23 19:55:22 +0200 |
---|---|---|
committer | Azul <azul@leap.se> | 2013-09-24 10:48:32 +0200 |
commit | 193bf6446b384dce1699e8fb82be6f16cb8cb5f6 (patch) | |
tree | fb4ed9b5a383a04c491ea0d1a54a413117028f24 /users/app/assets/javascripts | |
parent | 98db0cc42019dfcd90d58e0126fe691590fde2e2 (diff) |
use token auth when accessing the api from webapp
One failing integration test still needs to be fixed
Diffstat (limited to 'users/app/assets/javascripts')
m--------- | users/app/assets/javascripts/srp | 0 | ||||
-rw-r--r-- | users/app/assets/javascripts/users.js | 20 |
2 files changed, 19 insertions, 1 deletions
diff --git a/users/app/assets/javascripts/srp b/users/app/assets/javascripts/srp -Subproject 9c61d52f1f975ec0eefe5b4a0b71ac529300cbe +Subproject d22bf3b9fe2fd31192e1e1b358e97e5a0f3f90b diff --git a/users/app/assets/javascripts/users.js b/users/app/assets/javascripts/users.js index 4c9b510..9d1a0f0 100644 --- a/users/app/assets/javascripts/users.js +++ b/users/app/assets/javascripts/users.js @@ -3,7 +3,12 @@ // LOCAL FUNCTIONS // - var poll_users, prevent_default, form_failed, form_passed, clear_errors; + var poll_users, + prevent_default, + form_failed, + form_passed, + clear_errors, + update_user; prevent_default = function(event) { return event.preventDefault(); @@ -19,6 +24,17 @@ return $('#messages').empty(); }; + update_user = function(submitEvent) { + var form = submitEvent.target; + var token = form.dataset.token; + var url = form.action; + return $.ajax({ + url: url, + type: 'PUT', + headers: { Authorization: 'Token token="' + token + '"' }, + data: $(form).serialize() + }); + }; // // PUBLIC FUNCTIONS @@ -76,6 +92,8 @@ $('#new_session').submit(srp.login); $('#update_login_and_password').submit(prevent_default); $('#update_login_and_password').submit(srp.update); + $('#update_pgp_key').submit(prevent_default); + $('#update_pgp_key').submit(update_user); return $('#user-typeahead').typeahead({ source: poll_users }); |