Updated refresh token endpoint to enable rotation
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { getRequest, postRequest } from '.';
|
||||
import { ResponseUser } from './auth.types';
|
||||
import { RegisterUser, ResponseUser } from './auth.types';
|
||||
|
||||
export async function login(email: string, password: string): Promise<ResponseUser | undefined> {
|
||||
const response = await postRequest('auth/login', { email, password }, { withCredentials: true });
|
||||
@@ -10,10 +10,28 @@ export async function login(email: string, password: string): Promise<ResponseUs
|
||||
}
|
||||
}
|
||||
|
||||
export async function register(user: RegisterUser): Promise<boolean> {
|
||||
const response = await postRequest('auth/register', user, { withCredentials: true });
|
||||
if (response?.status === 201) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export async function logout() {
|
||||
return await postRequest('auth/logout', {}, { withCredentials: true });
|
||||
}
|
||||
|
||||
export async function refresh(refresh_token_rotation?: boolean): Promise<ResponseUser | undefined> {
|
||||
const response = await getRequest('auth/refresh', { withCredentials: true, params: { refresh_token_rotation } });
|
||||
if (response?.status === 200) {
|
||||
return response.data as ResponseUser;
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
export async function me(): Promise<ResponseUser | undefined> {
|
||||
const response = await getRequest('auth/me', { withCredentials: true });
|
||||
if (response?.status === 200) {
|
||||
|
||||
Reference in New Issue
Block a user