mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-24 20:36: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 { DIALOGS } from '../modal/constants';
|
||||
import { IResultWithStatus } from '../types';
|
||||
import { IToken, IUser } from './types';
|
||||
import { IUser } from './types';
|
||||
|
||||
export function* reqWrapper(requestAction, props = {}): ReturnType<typeof requestAction> {
|
||||
const { access } = yield select(selectToken);
|
||||
|
@ -29,17 +29,15 @@ export function* reqWrapper(requestAction, props = {}): ReturnType<typeof reques
|
|||
return result;
|
||||
}
|
||||
|
||||
function* sendLoginRequestSaga({ username, password }: ReturnType<typeof ActionCreators.userSendLoginRequest>): SagaIterator {
|
||||
function* sendLoginRequestSaga({ username, password }: ReturnType<typeof ActionCreators.userSendLoginRequest>) {
|
||||
if (!username || !password) return;
|
||||
|
||||
const { error, data: { token, user } }: IResultWithStatus<{ token: string; user: IUser }> = yield call(apiUserLogin, { username, password });
|
||||
|
||||
console.log({ token, error });
|
||||
|
||||
if (error) return yield put(userSetLoginError(error));
|
||||
if (error) { yield put(userSetLoginError(error)); return; }
|
||||
|
||||
yield put(authSetToken(token));
|
||||
yield put(authSetUser(user));
|
||||
yield put(authSetUser({ ...user, is_user: true }));
|
||||
yield put(modalSetShown(false));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue