mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
fixed auth
This commit is contained in:
parent
87d59b4905
commit
92f097d161
1 changed files with 4 additions and 6 deletions
|
@ -12,7 +12,7 @@ import { selectToken } from './selectors';
|
||||||
import { URLS } from '~/constants/urls';
|
import { URLS } from '~/constants/urls';
|
||||||
import { DIALOGS } from '../modal/constants';
|
import { DIALOGS } from '../modal/constants';
|
||||||
import { IResultWithStatus } from '../types';
|
import { IResultWithStatus } from '../types';
|
||||||
import { IToken, IUser } from './types';
|
import { IUser } from './types';
|
||||||
|
|
||||||
export function* reqWrapper(requestAction, props = {}): ReturnType<typeof requestAction> {
|
export function* reqWrapper(requestAction, props = {}): ReturnType<typeof requestAction> {
|
||||||
const { access } = yield select(selectToken);
|
const { access } = yield select(selectToken);
|
||||||
|
@ -29,17 +29,15 @@ export function* reqWrapper(requestAction, props = {}): ReturnType<typeof reques
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function* sendLoginRequestSaga({ username, password }: ReturnType<typeof ActionCreators.userSendLoginRequest>): SagaIterator {
|
function* sendLoginRequestSaga({ username, password }: ReturnType<typeof ActionCreators.userSendLoginRequest>) {
|
||||||
if (!username || !password) return;
|
if (!username || !password) return;
|
||||||
|
|
||||||
const { error, data: { token, user } }: IResultWithStatus<{ token: string; user: IUser }> = yield call(apiUserLogin, { username, password });
|
const { error, data: { token, user } }: IResultWithStatus<{ token: string; user: IUser }> = yield call(apiUserLogin, { username, password });
|
||||||
|
|
||||||
console.log({ token, error });
|
if (error) { yield put(userSetLoginError(error)); return; }
|
||||||
|
|
||||||
if (error) return yield put(userSetLoginError(error));
|
|
||||||
|
|
||||||
yield put(authSetToken(token));
|
yield put(authSetToken(token));
|
||||||
yield put(authSetUser(user));
|
yield put(authSetUser({ ...user, is_user: true }));
|
||||||
yield put(modalSetShown(false));
|
yield put(modalSetShown(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue