moar routing/auth refactorings
This commit is contained in:
parent
c4b91108a0
commit
853606bcc6
|
@ -30,23 +30,21 @@ Travis.reopen
|
||||||
@store = Travis.Store.create()
|
@store = Travis.Store.create()
|
||||||
@store.loadMany(Travis.Sponsor, Travis.SPONSORS)
|
@store.loadMany(Travis.Sponsor, Travis.SPONSORS)
|
||||||
|
|
||||||
# @set('auth', Travis.Auth.create(app: this, endpoint: Travis.config.api_endpoint))
|
|
||||||
|
|
||||||
@slider = new Travis.Slider()
|
@slider = new Travis.Slider()
|
||||||
@pusher = new Travis.Pusher(Travis.config.pusher_key)
|
@pusher = new Travis.Pusher(Travis.config.pusher_key)
|
||||||
@tailing = new Travis.Tailing()
|
@tailing = new Travis.Tailing()
|
||||||
|
|
||||||
initAuth: (router, path) ->
|
@set('auth', Travis.Auth.create(app: this, endpoint: Travis.config.api_endpoint))
|
||||||
auth = Travis.Auth.create(app: this, router: router, endpoint: Travis.config.api_endpoint)
|
|
||||||
@set('auth', auth)
|
storeAfterSignInPath: (path) ->
|
||||||
auth.loadUser(path)
|
@get('auth').storeAfterSignInPath(path)
|
||||||
|
|
||||||
|
autoSignIn: (path) ->
|
||||||
|
@get('auth').autoSignIn(path)
|
||||||
|
|
||||||
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')
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
init: ->
|
init: ->
|
||||||
@iframe.appendTo('body')
|
@iframe.appendTo('body')
|
||||||
window.addEventListener('message', (e) => @receiveMessage(e))
|
window.addEventListener('message', (e) => @receiveMessage(e))
|
||||||
# @loadUser()
|
|
||||||
|
|
||||||
accessToken: (->
|
accessToken: (->
|
||||||
sessionStorage.getItem('travis.token')
|
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
|
# 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.
|
# for auto signin then we're trying to sign in.
|
||||||
loadUser: (path)->
|
autoSignIn: (path) ->
|
||||||
|
console.log(path)
|
||||||
@storeAfterSignInPath(path)
|
@storeAfterSignInPath(path)
|
||||||
if user = sessionStorage.getItem('travis.user')
|
if user = sessionStorage.getItem('travis.user')
|
||||||
@setData(user: JSON.parse(user))
|
@setData(user: JSON.parse(user))
|
||||||
else
|
else if localStorage.getItem('travis.auto_signin')
|
||||||
@autoSignIn()
|
@signIn()
|
||||||
|
|
||||||
# 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: (path) ->
|
signIn: () ->
|
||||||
@set('state', 'signing-in')
|
@set('state', 'signing-in')
|
||||||
@trySignIn()
|
@trySignIn()
|
||||||
Ember.run.later(this, @checkSignIn.bind(this), @timeout)
|
Ember.run.later(this, @checkSignIn.bind(this), @timeout)
|
||||||
|
|
||||||
autoSignIn: (path) ->
|
|
||||||
@signIn(path) if localStorage.getItem('travis.auto_signin')
|
|
||||||
|
|
||||||
signOut: ->
|
signOut: ->
|
||||||
localStorage.removeItem('travis.auto_signin')
|
localStorage.removeItem('travis.auto_signin')
|
||||||
localStorage.removeItem('travis.locale')
|
localStorage.removeItem('travis.locale')
|
||||||
|
@ -56,7 +53,7 @@
|
||||||
@afterSignIn()
|
@afterSignIn()
|
||||||
|
|
||||||
afterSignIn: ->
|
afterSignIn: ->
|
||||||
@get('router').send('afterSignIn', @readAfterSignInPath())
|
@get('app.router').send('afterSignIn', @readAfterSignInPath())
|
||||||
|
|
||||||
storeToken: (token) ->
|
storeToken: (token) ->
|
||||||
sessionStorage.setItem('travis.token', token)
|
sessionStorage.setItem('travis.token', token)
|
||||||
|
|
|
@ -155,10 +155,11 @@ Travis.Router = Ember.Router.extend
|
||||||
routePath: (router, path) ->
|
routePath: (router, path) ->
|
||||||
router.saveLineNumberHash(path)
|
router.saveLineNumberHash(path)
|
||||||
router.authorize(path)
|
router.authorize(path)
|
||||||
router.auth = Travis.app.initAuth(router, path)
|
Travis.app.autoSignIn() unless router.signedIn()
|
||||||
|
|
||||||
authorize: (path) ->
|
authorize: (path) ->
|
||||||
if !@signedIn() && @needsAuth(path)
|
if !@signedIn() && @needsAuth(path)
|
||||||
|
Travis.app.storeAfterSignInPath(path)
|
||||||
@transitionTo('root.auth')
|
@transitionTo('root.auth')
|
||||||
else
|
else
|
||||||
@transitionTo('root')
|
@transitionTo('root')
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
|
|
||||||
#profile
|
#profile
|
||||||
#main
|
#main
|
||||||
|
h3
|
||||||
|
height: 19px
|
||||||
|
line-height: 19px
|
||||||
|
|
||||||
img
|
img
|
||||||
float: left
|
float: left
|
||||||
width: 48px
|
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 */
|
/* 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 {
|
#profile #main img {
|
||||||
float: left;
|
float: left;
|
||||||
width: 48px;
|
width: 48px;
|
||||||
|
@ -5094,33 +5099,33 @@ pre#log .fold.open {
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
background-color: #dddddd;
|
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 {
|
#profile #main dl {
|
||||||
float: left;
|
float: left;
|
||||||
margin: 0 0 20px 0;
|
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 {
|
#profile #main dt {
|
||||||
display: block;
|
display: block;
|
||||||
clear: left;
|
clear: left;
|
||||||
float: left;
|
float: left;
|
||||||
width: 50px;
|
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 {
|
#profile #main dd {
|
||||||
float: left;
|
float: left;
|
||||||
margin-left: 0;
|
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 {
|
#profile #main form {
|
||||||
clear: left;
|
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 {
|
#profile #main .tip {
|
||||||
margin-top: -5px;
|
margin-top: -5px;
|
||||||
color: #999999;
|
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 {
|
#profile #main .message {
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
padding: 10px 10px;
|
padding: 10px 10px;
|
||||||
|
@ -5132,7 +5137,7 @@ pre#log .fold.open {
|
||||||
-o-border-radius: 4px;
|
-o-border-radius: 4px;
|
||||||
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 {
|
#profile #main .message .sync_now {
|
||||||
float: right;
|
float: right;
|
||||||
margin-top: -3px;
|
margin-top: -3px;
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
0d94ee33
|
1ded0977
|
Loading…
Reference in New Issue
Block a user