From 92f097d161237604cdaa0b55b8ff126baf3d1d75 Mon Sep 17 00:00:00 2001 From: muerwre Date: Fri, 9 Aug 2019 15:40:50 +0700 Subject: [PATCH] fixed auth --- src/redux/auth/sagas.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/redux/auth/sagas.ts b/src/redux/auth/sagas.ts index 23656fd1..83149cfd 100644 --- a/src/redux/auth/sagas.ts +++ b/src/redux/auth/sagas.ts @@ -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 { const { access } = yield select(selectToken); @@ -29,17 +29,15 @@ export function* reqWrapper(requestAction, props = {}): ReturnType): SagaIterator { +function* sendLoginRequestSaga({ username, password }: ReturnType) { 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)); }