@@ -2,7 +2,7 @@ import '@ngrx/core/add/operator/select';
22import 'rxjs/add/operator/map' ;
33import 'rxjs/add/operator/let' ;
44import { AuthState , initialState } from './auth.state' ;
5- import { Actions , ActionTypes } from './auth.actions' ;
5+ import { Actions , ActionTypes , ProcessTokenAction , AuthErrorAction } from './auth.actions' ;
66import { AuthService } from './auth.service' ;
77
88export function authReducer ( state = initialState , action : Actions ) : AuthState {
@@ -12,16 +12,18 @@ export function authReducer(state = initialState, action: Actions): AuthState {
1212 return Object . assign ( { } , initialState ) ;
1313
1414 case ActionTypes . PROCESS_TOKEN :
15- const userData = AuthService . decodeAccessToken ( action . jwtToken ) ;
15+ const processTokenAction : ProcessTokenAction = action as ProcessTokenAction ;
16+ const userData = AuthService . decodeAccessToken ( processTokenAction . jwtToken ) ;
1617 return Object . assign ( { } , initialState , {
1718 authenticated : true ,
1819 tokenExpirationDate : new Date ( userData . exp * 1000 ) ,
1920 userData : userData ,
20- jwtToken : action . jwtToken
21+ jwtToken : processTokenAction . jwtToken
2122 } ) ;
2223
2324 case ActionTypes . AUTH_ERROR :
24- return Object . assign ( { } , userData , { error : action . error } ) ;
25+ const authErrorAction : AuthErrorAction = action as AuthErrorAction ;
26+ return Object . assign ( { } , userData , { error : authErrorAction . error } ) ;
2527
2628 case ActionTypes . CLEAR_AUTH_ERROR :
2729 return Object . assign ( { } , userData , { error : null } ) ;
0 commit comments