@@ -170,7 +170,7 @@ export class AngularTokenService implements CanActivate {
170
170
*/
171
171
172
172
// Register request
173
- registerAccount ( registerData : RegisterData , additionalData ?: any ) : Observable < any > {
173
+ registerAccount ( registerData : RegisterData , additionalData ?: any ) : Observable < ApiResponse > {
174
174
175
175
registerData = Object . assign ( { } , registerData ) ;
176
176
@@ -199,16 +199,18 @@ export class AngularTokenService implements CanActivate {
199
199
200
200
registerData . confirm_success_url = this . options . registerAccountCallback ;
201
201
202
- return this . http . post ( this . getServerPath ( ) + this . options . registerAccountPath , registerData ) ;
202
+ return this . http . post < ApiResponse > (
203
+ this . getServerPath ( ) + this . options . registerAccountPath , registerData
204
+ ) ;
203
205
}
204
206
205
207
// Delete Account
206
- deleteAccount ( ) : Observable < any > {
207
- return this . http . delete ( this . getServerPath ( ) + this . options . deleteAccountPath ) ;
208
+ deleteAccount ( ) : Observable < ApiResponse > {
209
+ return this . http . delete < ApiResponse > ( this . getServerPath ( ) + this . options . deleteAccountPath ) ;
208
210
}
209
211
210
212
// Sign in request and set storage
211
- signIn ( signInData : SignInData , additionalData ?: any ) : Observable < any > {
213
+ signIn ( signInData : SignInData , additionalData ?: any ) : Observable < ApiResponse > {
212
214
this . userType = ( signInData . userType == null ) ? null : this . getUserTypeByName ( signInData . userType ) ;
213
215
214
216
const body = {
@@ -220,11 +222,11 @@ export class AngularTokenService implements CanActivate {
220
222
body . additionalData = additionalData ;
221
223
}
222
224
223
- const observ = this . http . post < ApiResponse < UserData > > (
224
- this . getServerPath ( ) + this . options . signInPath , body , { observe : 'response' }
225
+ const observ = this . http . post < ApiResponse > (
226
+ this . getServerPath ( ) + this . options . signInPath , body
225
227
) . pipe ( share ( ) ) ;
226
228
227
- observ . subscribe ( res => this . userData = res . body . data ) ;
229
+ observ . subscribe ( res => this . userData = res . data ) ;
228
230
229
231
return observ ;
230
232
}
@@ -267,30 +269,30 @@ export class AngularTokenService implements CanActivate {
267
269
}
268
270
269
271
// Sign out request and delete storage
270
- signOut ( ) : Observable < any > {
271
- const observ = this . http . delete < any > ( this . getServerPath ( ) + this . options . signOutPath )
272
- // Only remove the localStorage and clear the data after the call
273
- . pipe (
274
- finalize ( ( ) => {
275
- this . localStorage . removeItem ( 'accessToken' ) ;
276
- this . localStorage . removeItem ( 'client' ) ;
277
- this . localStorage . removeItem ( 'expiry' ) ;
278
- this . localStorage . removeItem ( 'tokenType' ) ;
279
- this . localStorage . removeItem ( 'uid' ) ;
280
-
281
- this . authData = null ;
282
- this . userType = null ;
283
- this . userData = null ;
284
- }
285
- )
286
- ) ;
287
-
288
- return observ ;
272
+ signOut ( ) : Observable < ApiResponse > {
273
+ return this . http . delete < ApiResponse > ( this . getServerPath ( ) + this . options . signOutPath )
274
+ // Only remove the localStorage and clear the data after the call
275
+ . pipe (
276
+ finalize ( ( ) => {
277
+ this . localStorage . removeItem ( 'accessToken' ) ;
278
+ this . localStorage . removeItem ( 'client' ) ;
279
+ this . localStorage . removeItem ( 'expiry' ) ;
280
+ this . localStorage . removeItem ( 'tokenType' ) ;
281
+ this . localStorage . removeItem ( 'uid' ) ;
282
+
283
+ this . authData = null ;
284
+ this . userType = null ;
285
+ this . userData = null ;
286
+ }
287
+ )
288
+ ) ;
289
289
}
290
290
291
291
// Validate token request
292
- validateToken ( ) : Observable < any > {
293
- const observ = this . http . get < ApiResponse < UserData > > ( this . getServerPath ( ) + this . options . validateTokenPath ) . pipe ( share ( ) ) ;
292
+ validateToken ( ) : Observable < ApiResponse > {
293
+ const observ = this . http . get < ApiResponse > (
294
+ this . getServerPath ( ) + this . options . validateTokenPath
295
+ ) . pipe ( share ( ) ) ;
294
296
295
297
observ . subscribe (
296
298
( res ) => this . userData = res . data ,
@@ -304,7 +306,7 @@ export class AngularTokenService implements CanActivate {
304
306
}
305
307
306
308
// Update password request
307
- updatePassword ( updatePasswordData : UpdatePasswordData ) : Observable < any > {
309
+ updatePassword ( updatePasswordData : UpdatePasswordData ) : Observable < ApiResponse > {
308
310
309
311
if ( updatePasswordData . userType != null ) {
310
312
this . userType = this . getUserTypeByName ( updatePasswordData . userType ) ;
@@ -330,11 +332,11 @@ export class AngularTokenService implements CanActivate {
330
332
}
331
333
332
334
const body = args ;
333
- return this . http . put ( this . getServerPath ( ) + this . options . updatePasswordPath , body ) ;
335
+ return this . http . put < ApiResponse > ( this . getServerPath ( ) + this . options . updatePasswordPath , body ) ;
334
336
}
335
337
336
338
// Reset password request
337
- resetPassword ( resetPasswordData : ResetPasswordData ) : Observable < any > {
339
+ resetPassword ( resetPasswordData : ResetPasswordData ) : Observable < ApiResponse > {
338
340
339
341
this . userType = ( resetPasswordData . userType == null ) ? null : this . getUserTypeByName ( resetPasswordData . userType ) ;
340
342
@@ -343,7 +345,7 @@ export class AngularTokenService implements CanActivate {
343
345
redirect_url : this . options . resetPasswordCallback
344
346
} ;
345
347
346
- return this . http . post ( this . getServerPath ( ) + this . options . resetPasswordPath , body ) ;
348
+ return this . http . post < ApiResponse > ( this . getServerPath ( ) + this . options . resetPasswordPath , body ) ;
347
349
}
348
350
349
351
0 commit comments