mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
getting token / error
This commit is contained in:
parent
956802d5a5
commit
dc6f72baf1
26 changed files with 269 additions and 374 deletions
14
src/redux/auth/transforms.ts
Normal file
14
src/redux/auth/transforms.ts
Normal file
|
@ -0,0 +1,14 @@
|
|||
import {IResultWithStatus} from "~/redux/types";
|
||||
|
||||
export const userLoginTransform = ({ status, data,error }: IResultWithStatus<any>): IResultWithStatus<any> => {
|
||||
switch(true) {
|
||||
case status === 401 || !data.access || data.refresh:
|
||||
return { status, data, error: 'Пользователь не найден' };
|
||||
|
||||
case status === 200:
|
||||
return { status, data, error: null };
|
||||
|
||||
default:
|
||||
return { status, data, error: error || 'Неизвестная ошибка' };
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue