1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-24 20:36:40 +07:00

fixed social registration on login

This commit is contained in:
Fedor Katurov 2021-03-05 09:51:38 +07:00
parent b91ff98491
commit 455c7ad90d
2 changed files with 10 additions and 18 deletions

View file

@ -28,15 +28,4 @@
:global(.green) {
color: $wisegreen;
}
//&:last-child {
// p {
// &::after {
// content: '';
// display: inline-flex;
// height: 1em;
// width: 150px;
// }
// }
//}
}

View file

@ -57,6 +57,7 @@ import { ERRORS } from '~/constants/errors';
import { messagesSet } from '~/redux/messages/actions';
import { SagaIterator } from 'redux-saga';
import { isEmpty } from 'ramda';
import { AxiosError } from 'axios';
function* setTokenSaga({ token }: ReturnType<typeof authSetToken>) {
localStorage.setItem('token', token);
@ -341,13 +342,6 @@ function* loginWithSocial({ token }: ReturnType<typeof authLoginWithSocial>) {
token,
});
// Backend asks us for account registration
if (data?.needs_register) {
yield put(authSetRegisterSocial({ token }));
yield put(modalShowDialog(DIALOGS.LOGIN_SOCIAL_REGISTER));
return;
}
if (data.token) {
yield put(authSetToken(data.token));
yield call(refreshUser);
@ -355,6 +349,15 @@ function* loginWithSocial({ token }: ReturnType<typeof authLoginWithSocial>) {
return;
}
} catch (error) {
const data = (error as AxiosError<{ needs_register: boolean }>).response?.data;
// Backend asks us for account registration
if (data?.needs_register) {
yield put(authSetRegisterSocial({ token }));
yield put(modalShowDialog(DIALOGS.LOGIN_SOCIAL_REGISTER));
return;
}
yield put(userSetLoginError(error.message));
}
}