Updated auth types
This commit is contained in:
@@ -1,13 +1,24 @@
|
||||
import { getRequest, postRequest } from '.';
|
||||
import { ResponseUser } from './auth.types';
|
||||
|
||||
export async function login(email: string, password: string) {
|
||||
return await postRequest('auth/login', { email, password }, { withCredentials: true });
|
||||
export async function login(email: string, password: string): Promise<ResponseUser | undefined> {
|
||||
const response = await postRequest('auth/login', { email, password }, { withCredentials: true });
|
||||
if (response?.status === 200) {
|
||||
return response.data as ResponseUser;
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
export async function logout() {
|
||||
return await postRequest('auth/logout', {}, { withCredentials: true });
|
||||
}
|
||||
|
||||
export async function me() {
|
||||
return await getRequest('auth/me', { withCredentials: true });
|
||||
export async function me(): Promise<ResponseUser | undefined> {
|
||||
const response = await getRequest('auth/me', { withCredentials: true });
|
||||
if (response?.status === 200) {
|
||||
return response.data;
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user