add autoSignIn to fix that after signOut it would always re-signin on pages that require auth
This commit is contained in:
parent
44d81af450
commit
d84b5dfd0a
|
@ -39,6 +39,9 @@ Travis.reopen
|
||||||
signIn: ->
|
signIn: ->
|
||||||
@get('auth').signIn()
|
@get('auth').signIn()
|
||||||
|
|
||||||
|
autoSignIn: ->
|
||||||
|
@get('auth').autoSignIn()
|
||||||
|
|
||||||
signOut: ->
|
signOut: ->
|
||||||
@get('auth').signOut()
|
@get('auth').signOut()
|
||||||
@get('router').send('afterSignOut')
|
@get('router').send('afterSignOut')
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
loadUser: ->
|
loadUser: ->
|
||||||
if user = sessionStorage.getItem('travis.user')
|
if user = sessionStorage.getItem('travis.user')
|
||||||
@setData(user: JSON.parse(user))
|
@setData(user: JSON.parse(user))
|
||||||
else if localStorage.getItem('travis.auto_signin')
|
else
|
||||||
@trySignIn()
|
@autoSignIn()
|
||||||
|
|
||||||
# try signing in, but check later in case we have a timeout
|
# try signing in, but check later in case we have a timeout
|
||||||
signIn: ->
|
signIn: ->
|
||||||
|
@ -27,6 +27,14 @@
|
||||||
@trySignIn()
|
@trySignIn()
|
||||||
Ember.run.later(this, @checkSignIn.bind(this), @timeout)
|
Ember.run.later(this, @checkSignIn.bind(this), @timeout)
|
||||||
|
|
||||||
|
autoSignIn: ->
|
||||||
|
@signIn() if localStorage.getItem('travis.auto_signin')
|
||||||
|
|
||||||
|
signOut: ->
|
||||||
|
localStorage.clear()
|
||||||
|
sessionStorage.clear()
|
||||||
|
@setData()
|
||||||
|
|
||||||
trySignIn: ->
|
trySignIn: ->
|
||||||
@iframe.attr('src', "#{@endpoint}/auth/post_message?origin=#{@receivingEnd}")
|
@iframe.attr('src', "#{@endpoint}/auth/post_message?origin=#{@receivingEnd}")
|
||||||
|
|
||||||
|
@ -37,11 +45,6 @@
|
||||||
localStorage.setItem('travis.auto_signin', 'true')
|
localStorage.setItem('travis.auto_signin', 'true')
|
||||||
window.location = "#{@endpoint}/auth/handshake?redirect_uri=#{location}"
|
window.location = "#{@endpoint}/auth/handshake?redirect_uri=#{location}"
|
||||||
|
|
||||||
signOut: ->
|
|
||||||
localStorage?.clear()
|
|
||||||
sessionStorage?.clear()
|
|
||||||
@setData()
|
|
||||||
|
|
||||||
setData: (data) ->
|
setData: (data) ->
|
||||||
data = JSON.parse(data) if typeof data == 'string'
|
data = JSON.parse(data) if typeof data == 'string'
|
||||||
@storeToken(data.token) if data?.token
|
@storeToken(data.token) if data?.token
|
||||||
|
|
|
@ -148,24 +148,27 @@ Travis.Router = Ember.Router.extend
|
||||||
path.indexOf('/profile') == 0
|
path.indexOf('/profile') == 0
|
||||||
|
|
||||||
afterSignIn: ->
|
afterSignIn: ->
|
||||||
after_signin_path = sessionStorage.getItem('travis.after_signin_path')
|
path = sessionStorage.getItem('travis.after_signin_path')
|
||||||
sessionStorage.removeItem('travis.after_signin_path')
|
sessionStorage.removeItem('travis.after_signin_path')
|
||||||
@transitionTo('root')
|
@transitionTo('root')
|
||||||
@route(after_signin_path || '/')
|
@route(path || '/')
|
||||||
|
|
||||||
afterSignOut: ->
|
afterSignOut: ->
|
||||||
@transitionTo('loading')
|
@authorize('/')
|
||||||
|
|
||||||
|
authorize: (path) ->
|
||||||
|
if !@signedIn() && @needsAuth(path)
|
||||||
|
sessionStorage.setItem('travis.after_signin_path', path)
|
||||||
|
@transitionTo('root.auth')
|
||||||
|
Travis.app.autoSignIn()
|
||||||
|
else
|
||||||
|
@transitionTo('root')
|
||||||
|
@route(path)
|
||||||
|
|
||||||
loading: Ember.Route.extend
|
loading: Ember.Route.extend
|
||||||
routePath: (router, path) ->
|
routePath: (router, path) ->
|
||||||
router.saveLineNumberHash(path)
|
router.saveLineNumberHash(path)
|
||||||
if !router.signedIn() && router.needsAuth(path)
|
router.authorize(path)
|
||||||
sessionStorage.setItem('travis.after_signin_path', path)
|
|
||||||
router.transitionTo('root.auth')
|
|
||||||
Travis.app.signIn()
|
|
||||||
else
|
|
||||||
router.transitionTo('root')
|
|
||||||
router.route(path)
|
|
||||||
|
|
||||||
root: Ember.Route.extend
|
root: Ember.Route.extend
|
||||||
route: '/'
|
route: '/'
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1 +1 @@
|
||||||
b35f89d1
|
5fb464fb
|
Loading…
Reference in New Issue
Block a user