File tree Expand file tree Collapse file tree 2 files changed +8
-45
lines changed Expand file tree Collapse file tree 2 files changed +8
-45
lines changed Original file line number Diff line number Diff line change @@ -124,17 +124,13 @@ angular.module('neo4jApp.services')
124
124
login : ->
125
125
q = $q .defer ()
126
126
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 ()
138
134
)
139
135
q .promise
140
136
@@ -155,38 +151,9 @@ angular.module('neo4jApp.services')
155
151
156
152
isAuthenticated : -> localStorageService .get ' ntn_data_token'
157
153
158
- autoLogin : ->
159
- that = @
160
- q = $q .defer ()
161
- if NTN .isAuthenticated ()
162
- q .resolve ()
163
- return q .promise
164
- token = localStorageService .get (' ntn_token' )
165
- if not token
166
- q .reject ()
167
- return q .promise
168
- q .reject ()
169
- q .promise
170
-
171
- refreshToken : ->
172
- that = @
173
- NTN .refreshToken (localStorageService .get (' ntn_refresh_token' )).then ((token )->
174
- that .persist ({token : token .token , data_token : token .data_token })
175
- that .autoLogin ()
176
- )
177
-
178
154
init : ->
179
155
NTN .connection ()
180
156
181
- $rootScope .$on ' ntn:token_will_expire' , () ->
182
- cu .refreshToken ()
183
-
184
- $rootScope .$on ' ntn:token_expired' , () ->
185
- cu .autoLogin ()
186
-
187
- $rootScope .$on ' ntn:connection_status' , (s , isConnected ) ->
188
- if isConnected then cu .autoLogin ()
189
-
190
157
cu = new CurrentUser
191
158
cu
192
159
]
Original file line number Diff line number Diff line change @@ -41,10 +41,7 @@ angular.module('neo4jApp.services')
41
41
ref = new Firebase (" https://fiery-heat-7952.firebaseio.com/users/#{ id} /" )
42
42
fbauth = $firebaseAuth ref
43
43
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 ) ->
48
45
q .resolve (ref)
49
46
,
50
47
(err ) ->
@@ -63,7 +60,6 @@ angular.module('neo4jApp.services')
63
60
,
64
61
(err )->
65
62
_unbind ()
66
- $rootScope .$emit ' ntn:token_expired'
67
63
)
68
64
69
65
_push = (_store , data ) ->
You can’t perform that action at this time.
0 commit comments