mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
fixed social registration on login
This commit is contained in:
parent
b91ff98491
commit
455c7ad90d
2 changed files with 10 additions and 18 deletions
|
@ -28,15 +28,4 @@
|
||||||
:global(.green) {
|
:global(.green) {
|
||||||
color: $wisegreen;
|
color: $wisegreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
//&:last-child {
|
|
||||||
// p {
|
|
||||||
// &::after {
|
|
||||||
// content: '';
|
|
||||||
// display: inline-flex;
|
|
||||||
// height: 1em;
|
|
||||||
// width: 150px;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,7 @@ import { ERRORS } from '~/constants/errors';
|
||||||
import { messagesSet } from '~/redux/messages/actions';
|
import { messagesSet } from '~/redux/messages/actions';
|
||||||
import { SagaIterator } from 'redux-saga';
|
import { SagaIterator } from 'redux-saga';
|
||||||
import { isEmpty } from 'ramda';
|
import { isEmpty } from 'ramda';
|
||||||
|
import { AxiosError } from 'axios';
|
||||||
|
|
||||||
function* setTokenSaga({ token }: ReturnType<typeof authSetToken>) {
|
function* setTokenSaga({ token }: ReturnType<typeof authSetToken>) {
|
||||||
localStorage.setItem('token', token);
|
localStorage.setItem('token', token);
|
||||||
|
@ -341,13 +342,6 @@ function* loginWithSocial({ token }: ReturnType<typeof authLoginWithSocial>) {
|
||||||
token,
|
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) {
|
if (data.token) {
|
||||||
yield put(authSetToken(data.token));
|
yield put(authSetToken(data.token));
|
||||||
yield call(refreshUser);
|
yield call(refreshUser);
|
||||||
|
@ -355,6 +349,15 @@ function* loginWithSocial({ token }: ReturnType<typeof authLoginWithSocial>) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} 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));
|
yield put(userSetLoginError(error.message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue