Work towards authentication through opening window

This commit is contained in:
2014-08-18 18:20:58 +02:00
parent bfa6bb66b0
commit 268c5aabb9
8 changed files with 44 additions and 28 deletions
+17 -1
View File
@@ -15,7 +15,23 @@
# frame = $('<iframe></iframe>').addClass('obtain-token-frame').attr 'src', $obtain_token_url
# frame.css width: $('body').outerWidth(), height: $('body').outerHeight()
# $('body').append frame
window.location = "#{$obtain_token_url}"
# window.location = "#{$obtain_token_url}"
auth_win = window.open $obtain_token_url, "_blank", "location=no"
auth_win.addEventListener "loadstop", ->
# auth_win.executeScript(code: "localStorage.setItem( 'name', '' );")
watch_loop = setInterval ->
auth_win.executeScript {code: "localStorage.getItem( 'auth_token' )"}, (values)->
token = values[0]
if token
clearInterval( watch_loop )
auth_win.executeScript {code: "localStorage.setItem('auth_token', '');"}
auth_win.executeScript {code: "localStorage.getItem( 'user_id' )"}, (user_id_values)->
user_id = user_id_values[0]
Qstorage.setItem 'user_id', user_id
Qstorage.setItem 'auth_token', token
auth_win.close()
, 200
Ember.$.ajaxPrefilter (options) ->
if options.type.toUpperCase() == 'GET'