This repository has been archived on 2025-10-28. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
dashboard/src/services/auth/redux/actions.ts
2022-04-15 14:30:27 +02:00

32 lines
898 B
TypeScript

import { createApiAction } from 'src/services/api';
import { SuccessAction } from 'src/services/api/redux/types';
export enum AuthActionTypes {
SIGN_IN_START = 'auth/sign_in_start',
SIGN_IN_SUCCESS = 'auth/sign_in_success',
SIGN_IN_FAILURE = 'auth/sign_in_failure',
SIGN_OUT = 'auth/SIGN_OUT',
UPDATE_AUTH_USER = 'auth/update_auth_user',
REGISTRATION_START = 'auth/registration_start',
REGISTRATION_FAILURE = 'auth/registration_failure',
}
const signOutAction = (): SuccessAction => ({
type: AuthActionTypes.SIGN_OUT,
payload: null,
});
export const signIn = (params: string) =>
createApiAction(
{
path: `/hydra/callback${params}`,
method: 'GET',
},
[AuthActionTypes.SIGN_IN_START, AuthActionTypes.SIGN_IN_SUCCESS, AuthActionTypes.SIGN_IN_FAILURE],
);
export function signOut() {
return (dispatch: any) => {
dispatch(signOutAction());
};
}