mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-24 20:36:40 +07:00
login mechanism fixes
This commit is contained in:
parent
9528e7f699
commit
3982b894d7
1 changed files with 3 additions and 10 deletions
|
@ -9,21 +9,14 @@ import { push } from 'connected-react-router'
|
|||
function* sendLoginRequestSaga({ username, password }: ReturnType<typeof ActionCreators.userSendLoginRequest>): SagaIterator {
|
||||
if (!username || !password) return yield put(userSetLoginError({ error: USER_ERRORS.EMPTY_CREDENTIALS }));
|
||||
|
||||
const { token, status, user }: { token: string, status: number, user: IApiUser } = yield call(apiUserLogin, { username, password });
|
||||
const { token, status, user }:
|
||||
{ token: string, status: number, user: IApiUser } = yield call(apiUserLogin, { username, password });
|
||||
|
||||
if (!token) return yield put(userSetLoginError({ error: USER_STATUSES[status] || USER_ERRORS.INVALID_CREDENTIALS }));
|
||||
|
||||
const { id, role, email, activated } = user;
|
||||
|
||||
yield put(userSetUser({
|
||||
token,
|
||||
id,
|
||||
role,
|
||||
email,
|
||||
username: user.username,
|
||||
activated,
|
||||
}));
|
||||
|
||||
yield put(userSetUser({ token, id, role, email, username: user.username, activated, }));
|
||||
yield put(push('/'));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue