mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 21:06:42 +07:00
made saga open register dialog
This commit is contained in:
parent
837b4ee6f3
commit
f1463ed5ea
6 changed files with 19 additions and 13 deletions
|
@ -134,8 +134,8 @@ export const authLoginWithSocial = (token: string, username?: string, password?:
|
|||
password,
|
||||
});
|
||||
|
||||
export const authGotOauthEvent = (event: IOAuthEvent) => ({
|
||||
type: AUTH_USER_ACTIONS.GOT_OAUTH_EVENT,
|
||||
export const authGotOauthLoginEvent = (event: IOAuthEvent) => ({
|
||||
type: AUTH_USER_ACTIONS.GOT_OAUTH_LOGIN_EVENT,
|
||||
event,
|
||||
});
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ export const AUTH_USER_ACTIONS = {
|
|||
SET_SOCIALS: 'SET_SOCIALS',
|
||||
ATTACH_SOCIAL: 'ATTACH_SOCIAL',
|
||||
LOGIN_WITH_SOCIAL: 'LOGIN_WITH_SOCIAL',
|
||||
GOT_OAUTH_EVENT: 'GOT_OAUTH_EVENT',
|
||||
GOT_OAUTH_LOGIN_EVENT: 'GOT_OAUTH_EVENT',
|
||||
|
||||
SET_REGISTER_SOCIAL: 'SET_REGISTER_SOCIAL',
|
||||
SET_REGISTER_SOCIAL_ERRORS: 'SET_REGISTER_SOCIAL_ERRORS',
|
||||
|
|
|
@ -4,7 +4,7 @@ import {
|
|||
authAttachSocial,
|
||||
authDropSocial,
|
||||
authGetMessages,
|
||||
authGotOauthEvent,
|
||||
authGotOauthLoginEvent,
|
||||
authLoadProfile,
|
||||
authLoggedIn,
|
||||
authLoginWithSocial,
|
||||
|
@ -15,6 +15,7 @@ import {
|
|||
authSendMessage,
|
||||
authSetLastSeenMessages,
|
||||
authSetProfile,
|
||||
authSetRegisterSocial,
|
||||
authSetRestore,
|
||||
authSetSocials,
|
||||
authSetToken,
|
||||
|
@ -459,7 +460,9 @@ function* loginWithSocial({ token }: ReturnType<typeof authLoginWithSocial>) {
|
|||
error,
|
||||
}: Unwrap<ReturnType<typeof apiLoginWithSocial>> = yield call(apiLoginWithSocial, { token });
|
||||
|
||||
// Backend asks us for account registration
|
||||
if (data?.needs_register) {
|
||||
yield put(authSetRegisterSocial({ token }));
|
||||
yield put(modalShowDialog(DIALOGS.LOGIN_SOCIAL_REGISTER));
|
||||
return;
|
||||
}
|
||||
|
@ -479,7 +482,7 @@ function* loginWithSocial({ token }: ReturnType<typeof authLoginWithSocial>) {
|
|||
}
|
||||
}
|
||||
|
||||
function* gotOauthEvent({ event }: ReturnType<typeof authGotOauthEvent>) {
|
||||
function* gotOauthLoginEvent({ event }: ReturnType<typeof authGotOauthLoginEvent>) {
|
||||
if (!event?.type) return;
|
||||
|
||||
switch (event.type) {
|
||||
|
@ -493,6 +496,7 @@ function* gotOauthEvent({ event }: ReturnType<typeof authGotOauthEvent>) {
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function* authSaga() {
|
||||
yield takeEvery(REHYDRATE, checkUserSaga);
|
||||
yield takeLatest([REHYDRATE, AUTH_USER_ACTIONS.LOGGED_IN], startPollingSaga);
|
||||
|
@ -513,7 +517,7 @@ function* authSaga() {
|
|||
yield takeLatest(AUTH_USER_ACTIONS.DROP_SOCIAL, dropSocial);
|
||||
yield takeLatest(AUTH_USER_ACTIONS.ATTACH_SOCIAL, attachSocial);
|
||||
yield takeLatest(AUTH_USER_ACTIONS.LOGIN_WITH_SOCIAL, loginWithSocial);
|
||||
yield takeEvery(AUTH_USER_ACTIONS.GOT_OAUTH_EVENT, gotOauthEvent);
|
||||
yield takeEvery(AUTH_USER_ACTIONS.GOT_OAUTH_LOGIN_EVENT, gotOauthLoginEvent);
|
||||
}
|
||||
|
||||
export default authSaga;
|
||||
|
|
|
@ -8,3 +8,4 @@ export const selectAuthProfile = (state: IState) => state.auth.profile;
|
|||
export const selectAuthUser = (state: IState) => state.auth.user;
|
||||
export const selectAuthUpdates = (state: IState) => state.auth.updates;
|
||||
export const selectAuthRestore = (state: IState) => state.auth.restore;
|
||||
export const selectAuthRegisterSocial = (state: IState) => state.auth.register_social;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue