view data fixes
This commit is contained in:
8
apps/website/lib/gateways/api/auth/AuthApiClient.test.ts
Normal file
8
apps/website/lib/gateways/api/auth/AuthApiClient.test.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { AuthApiClient } from './AuthApiClient';
|
||||
|
||||
describe('AuthApiClient', () => {
|
||||
it('should be defined', () => {
|
||||
expect(AuthApiClient).toBeDefined();
|
||||
});
|
||||
});
|
||||
45
apps/website/lib/gateways/api/auth/AuthApiClient.ts
Normal file
45
apps/website/lib/gateways/api/auth/AuthApiClient.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { BaseApiClient } from '../base/BaseApiClient';
|
||||
import { AuthSessionDTO } from '../../types/generated/AuthSessionDTO';
|
||||
import { LoginParamsDTO } from '../../types/generated/LoginParamsDTO';
|
||||
import { SignupParamsDTO } from '../../types/generated/SignupParamsDTO';
|
||||
import { ForgotPasswordDTO } from '../../types/generated/ForgotPasswordDTO';
|
||||
import { ResetPasswordDTO } from '../../types/generated/ResetPasswordDTO';
|
||||
|
||||
/**
|
||||
* Auth API Client
|
||||
*
|
||||
* Handles all authentication-related API operations.
|
||||
*/
|
||||
export class AuthApiClient extends BaseApiClient {
|
||||
/** Sign up with email */
|
||||
signup(params: SignupParamsDTO): Promise<AuthSessionDTO> {
|
||||
return this.post<AuthSessionDTO>('/auth/signup', params);
|
||||
}
|
||||
|
||||
/** Login with email */
|
||||
login(params: LoginParamsDTO): Promise<AuthSessionDTO> {
|
||||
return this.post<AuthSessionDTO>('/auth/login', params);
|
||||
}
|
||||
|
||||
/** Get current session */
|
||||
getSession(): Promise<AuthSessionDTO | null> {
|
||||
return this.request<AuthSessionDTO | null>('GET', '/auth/session', undefined, {
|
||||
allowUnauthenticated: true,
|
||||
});
|
||||
}
|
||||
|
||||
/** Logout */
|
||||
logout(): Promise<void> {
|
||||
return this.post<void>('/auth/logout', {});
|
||||
}
|
||||
|
||||
/** Forgot password - send reset link */
|
||||
forgotPassword(params: ForgotPasswordDTO): Promise<{ message: string; magicLink?: string }> {
|
||||
return this.post<{ message: string; magicLink?: string }>('/auth/forgot-password', params);
|
||||
}
|
||||
|
||||
/** Reset password with token */
|
||||
resetPassword(params: ResetPasswordDTO): Promise<{ message: string }> {
|
||||
return this.post<{ message: string }>('/auth/reset-password', params);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user