moar routing/auth refactorings
This commit is contained in:
parent
c4b91108a0
commit
853606bcc6
|
@ -30,23 +30,21 @@ Travis.reopen
|
|||
@store = Travis.Store.create()
|
||||
@store.loadMany(Travis.Sponsor, Travis.SPONSORS)
|
||||
|
||||
# @set('auth', Travis.Auth.create(app: this, endpoint: Travis.config.api_endpoint))
|
||||
|
||||
@slider = new Travis.Slider()
|
||||
@pusher = new Travis.Pusher(Travis.config.pusher_key)
|
||||
@tailing = new Travis.Tailing()
|
||||
|
||||
initAuth: (router, path) ->
|
||||
auth = Travis.Auth.create(app: this, router: router, endpoint: Travis.config.api_endpoint)
|
||||
@set('auth', auth)
|
||||
auth.loadUser(path)
|
||||
@set('auth', Travis.Auth.create(app: this, endpoint: Travis.config.api_endpoint))
|
||||
|
||||
storeAfterSignInPath: (path) ->
|
||||
@get('auth').storeAfterSignInPath(path)
|
||||
|
||||
autoSignIn: (path) ->
|
||||
@get('auth').autoSignIn(path)
|
||||
|
||||
signIn: ->
|
||||
@get('auth').signIn()
|
||||
|
||||
# autoSignIn: ->
|
||||
# @get('auth').autoSignIn()
|
||||
|
||||
signOut: ->
|
||||
@get('auth').signOut()
|
||||
@get('router').send('afterSignOut')
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
init: ->
|
||||
@iframe.appendTo('body')
|
||||
window.addEventListener('message', (e) => @receiveMessage(e))
|
||||
# @loadUser()
|
||||
|
||||
accessToken: (->
|
||||
sessionStorage.getItem('travis.token')
|
||||
|
@ -15,22 +14,20 @@
|
|||
|
||||
# if the user is in the session storage, we're using it. if we have a flag
|
||||
# for auto signin then we're trying to sign in.
|
||||
loadUser: (path)->
|
||||
autoSignIn: (path) ->
|
||||
console.log(path)
|
||||
@storeAfterSignInPath(path)
|
||||
if user = sessionStorage.getItem('travis.user')
|
||||
@setData(user: JSON.parse(user))
|
||||
else
|
||||
@autoSignIn()
|
||||
else if localStorage.getItem('travis.auto_signin')
|
||||
@signIn()
|
||||
|
||||
# try signing in, but check later in case we have a timeout
|
||||
signIn: (path) ->
|
||||
signIn: () ->
|
||||
@set('state', 'signing-in')
|
||||
@trySignIn()
|
||||
Ember.run.later(this, @checkSignIn.bind(this), @timeout)
|
||||
|
||||
autoSignIn: (path) ->
|
||||
@signIn(path) if localStorage.getItem('travis.auto_signin')
|
||||
|
||||
signOut: ->
|
||||
localStorage.removeItem('travis.auto_signin')
|
||||
localStorage.removeItem('travis.locale')
|
||||
|
@ -56,7 +53,7 @@
|
|||
@afterSignIn()
|
||||
|
||||
afterSignIn: ->
|
||||
@get('router').send('afterSignIn', @readAfterSignInPath())
|
||||
@get('app.router').send('afterSignIn', @readAfterSignInPath())
|
||||
|
||||
storeToken: (token) ->
|
||||
sessionStorage.setItem('travis.token', token)
|
||||
|
|
|
@ -155,10 +155,11 @@ Travis.Router = Ember.Router.extend
|
|||
routePath: (router, path) ->
|
||||
router.saveLineNumberHash(path)
|
||||
router.authorize(path)
|
||||
router.auth = Travis.app.initAuth(router, path)
|
||||
Travis.app.autoSignIn() unless router.signedIn()
|
||||
|
||||
authorize: (path) ->
|
||||
if !@signedIn() && @needsAuth(path)
|
||||
Travis.app.storeAfterSignInPath(path)
|
||||
@transitionTo('root.auth')
|
||||
else
|
||||
@transitionTo('root')
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
|
||||
#profile
|
||||
#main
|
||||
h3
|
||||
height: 19px
|
||||
line-height: 19px
|
||||
|
||||
img
|
||||
float: left
|
||||
width: 48px
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -5082,6 +5082,11 @@ pre#log .fold.open {
|
|||
}
|
||||
|
||||
/* line 5, /Users/sven/Development/projects/travis/travis-web/assets/styles/profile.sass */
|
||||
#profile #main h3 {
|
||||
height: 19px;
|
||||
line-height: 19px;
|
||||
}
|
||||
/* line 9, /Users/sven/Development/projects/travis/travis-web/assets/styles/profile.sass */
|
||||
#profile #main img {
|
||||
float: left;
|
||||
width: 48px;
|
||||
|
@ -5094,33 +5099,33 @@ pre#log .fold.open {
|
|||
border-radius: 4px;
|
||||
background-color: #dddddd;
|
||||
}
|
||||
/* line 13, /Users/sven/Development/projects/travis/travis-web/assets/styles/profile.sass */
|
||||
/* line 17, /Users/sven/Development/projects/travis/travis-web/assets/styles/profile.sass */
|
||||
#profile #main dl {
|
||||
float: left;
|
||||
margin: 0 0 20px 0;
|
||||
}
|
||||
/* line 17, /Users/sven/Development/projects/travis/travis-web/assets/styles/profile.sass */
|
||||
/* line 21, /Users/sven/Development/projects/travis/travis-web/assets/styles/profile.sass */
|
||||
#profile #main dt {
|
||||
display: block;
|
||||
clear: left;
|
||||
float: left;
|
||||
width: 50px;
|
||||
}
|
||||
/* line 23, /Users/sven/Development/projects/travis/travis-web/assets/styles/profile.sass */
|
||||
/* line 27, /Users/sven/Development/projects/travis/travis-web/assets/styles/profile.sass */
|
||||
#profile #main dd {
|
||||
float: left;
|
||||
margin-left: 0;
|
||||
}
|
||||
/* line 27, /Users/sven/Development/projects/travis/travis-web/assets/styles/profile.sass */
|
||||
/* line 31, /Users/sven/Development/projects/travis/travis-web/assets/styles/profile.sass */
|
||||
#profile #main form {
|
||||
clear: left;
|
||||
}
|
||||
/* line 30, /Users/sven/Development/projects/travis/travis-web/assets/styles/profile.sass */
|
||||
/* line 34, /Users/sven/Development/projects/travis/travis-web/assets/styles/profile.sass */
|
||||
#profile #main .tip {
|
||||
margin-top: -5px;
|
||||
color: #999999;
|
||||
}
|
||||
/* line 34, /Users/sven/Development/projects/travis/travis-web/assets/styles/profile.sass */
|
||||
/* line 38, /Users/sven/Development/projects/travis/travis-web/assets/styles/profile.sass */
|
||||
#profile #main .message {
|
||||
margin-top: 20px;
|
||||
padding: 10px 10px;
|
||||
|
@ -5132,7 +5137,7 @@ pre#log .fold.open {
|
|||
-o-border-radius: 4px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
/* line 41, /Users/sven/Development/projects/travis/travis-web/assets/styles/profile.sass */
|
||||
/* line 45, /Users/sven/Development/projects/travis/travis-web/assets/styles/profile.sass */
|
||||
#profile #main .message .sync_now {
|
||||
float: right;
|
||||
margin-top: -3px;
|
||||
|
|
|
@ -1 +1 @@
|
|||
0d94ee33
|
||||
1ded0977
|
Loading…
Reference in New Issue
Block a user