Skip to content

Commit f75be3e

Browse files
committed
Merge pull request #160 from pe4cey/remove-auth0-direct-calls
Remove unused auth0 call for refreshing token
2 parents f7a4d6a + 42af753 commit f75be3e

File tree

2 files changed

+8
-45
lines changed

2 files changed

+8
-45
lines changed

app/scripts/services/CurrentUser.coffee

Lines changed: 7 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -124,17 +124,13 @@ angular.module('neo4jApp.services')
124124
login: ->
125125
q = $q.defer()
126126
that = @
127-
@autoLogin().then(
128-
->
129-
q.resolve()
130-
,
131-
->
132-
NTN.login().then((res) ->
133-
that.persist res
134-
data = localStorageService.get 'ntn_profile' || {}
135-
$rootScope.$emit 'ntn:login', data
136-
q.resolve(res)
137-
)
127+
NTN.login().then((res) ->
128+
that.persist res
129+
data = localStorageService.get 'ntn_profile' || {}
130+
$rootScope.$emit 'ntn:login', data
131+
q.resolve(res)
132+
,
133+
(err) -> q.reject()
138134
)
139135
q.promise
140136

@@ -156,38 +152,9 @@ angular.module('neo4jApp.services')
156152

157153
isAuthenticated: -> localStorageService.get 'ntn_data_token'
158154

159-
autoLogin: ->
160-
that = @
161-
q = $q.defer()
162-
if NTN.isAuthenticated()
163-
q.resolve()
164-
return q.promise
165-
token = localStorageService.get('ntn_token')
166-
if not token
167-
q.reject()
168-
return q.promise
169-
q.reject()
170-
q.promise
171-
172-
refreshToken: ->
173-
that = @
174-
NTN.refreshToken(localStorageService.get('ntn_refresh_token')).then((token)->
175-
that.persist({token: token.token, data_token: token.data_token})
176-
that.autoLogin()
177-
)
178-
179155
init: ->
180156
NTN.connection()
181157

182-
$rootScope.$on 'ntn:token_will_expire', () ->
183-
cu.refreshToken()
184-
185-
$rootScope.$on 'ntn:token_expired', () ->
186-
cu.autoLogin()
187-
188-
$rootScope.$on 'ntn:connection_status', (s, isConnected) ->
189-
if isConnected then cu.autoLogin()
190-
191158
cu = new CurrentUser
192159
cu
193160
]

app/scripts/services/NTN.coffee

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,7 @@ angular.module('neo4jApp.services')
4141
ref = new Firebase("https://fiery-heat-7952.firebaseio.com/users/#{id}/")
4242
fbauth = $firebaseAuth ref
4343
fbauth.$authWithCustomToken(token).then(
44-
(auth_data)->
45-
if auth_data.expires - Math.round((new Date()).getTime()/1000) < 60*60*12
46-
$rootScope.$emit 'ntn:token_will_expire'
47-
44+
(success) ->
4845
q.resolve(ref)
4946
,
5047
(err) ->
@@ -63,7 +60,6 @@ angular.module('neo4jApp.services')
6360
,
6461
(err)->
6562
_unbind()
66-
$rootScope.$emit 'ntn:token_expired'
6763
)
6864

6965
_push = (_store, data) ->

0 commit comments

Comments
 (0)