2018-05-28 12:37:47 +00:00
|
|
|
import {
|
|
|
|
Actions,
|
|
|
|
ActionType,
|
|
|
|
} from '../../entity/member-totp/member-totp.action';
|
|
|
|
|
|
|
|
import {
|
|
|
|
State,
|
|
|
|
initialState,
|
|
|
|
} from './member-totp.state';
|
|
|
|
|
|
|
|
export function reducer(state = initialState, action: Actions): State {
|
|
|
|
switch (action.type) {
|
|
|
|
case ActionType.CreateTotp: {
|
|
|
|
return {
|
|
|
|
secretKey: null,
|
|
|
|
sourceURI: null,
|
|
|
|
pending: true,
|
|
|
|
error: null,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
case ActionType.CreateTotpSuccess: {
|
|
|
|
return {
|
|
|
|
secretKey: action.payload.key,
|
|
|
|
sourceURI: action.payload.uri,
|
|
|
|
pending: false,
|
|
|
|
error: null,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
case ActionType.CreateTotpFailure: {
|
|
|
|
return {
|
|
|
|
secretKey: null,
|
|
|
|
sourceURI: null,
|
|
|
|
pending: false,
|
|
|
|
error: action.payload,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-05-29 09:32:22 +00:00
|
|
|
case ActionType.Regist: {
|
|
|
|
return {
|
|
|
|
secretKey: null,
|
|
|
|
sourceURI: null,
|
|
|
|
pending: true,
|
|
|
|
error: null,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
case ActionType.RegistSuccess: {
|
|
|
|
return {
|
|
|
|
secretKey: null,
|
|
|
|
sourceURI: null,
|
|
|
|
pending: true,
|
|
|
|
error: null,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
case ActionType.RegistFailure: {
|
|
|
|
return {
|
|
|
|
secretKey: null,
|
|
|
|
sourceURI: null,
|
|
|
|
pending: true,
|
|
|
|
error: action.payload,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
case ActionType.CheckCodeForMember: {
|
|
|
|
return {
|
|
|
|
secretKey: null,
|
|
|
|
sourceURI: null,
|
|
|
|
pending: true,
|
|
|
|
error: null,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
case ActionType.CheckCodeForMemberSuccess: {
|
|
|
|
return {
|
|
|
|
secretKey: null,
|
|
|
|
sourceURI: null,
|
|
|
|
pending: true,
|
|
|
|
error: null,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
case ActionType.CheckCodeForMemberFailure: {
|
|
|
|
return {
|
|
|
|
secretKey: null,
|
|
|
|
sourceURI: null,
|
|
|
|
pending: true,
|
|
|
|
error: action.payload,
|
|
|
|
};
|
|
|
|
}
|
2018-05-28 12:37:47 +00:00
|
|
|
default: {
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|