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
@@ -156,38 +152,9 @@ angular.module('neo4jApp.services')
156
152
157
153
isAuthenticated : -> localStorageService .get ' ntn_data_token'
158
154
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
-
179
155
init : ->
180
156
NTN .connection ()
181
157
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
-
191
158
cu = new CurrentUser
192
159
cu
193
160
]
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