view models
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import { AuthApiClient } from '../../api/auth/AuthApiClient';
|
||||
import { SessionViewModel } from '../../view-models/SessionViewModel';
|
||||
|
||||
// TODO: Move these types to apps/website/lib/types/generated when available
|
||||
// TODO: Create DTOs for login/signup params in apps/website/lib/types/generated
|
||||
type LoginParamsDto = { email: string; password: string };
|
||||
type SignupParamsDto = { email: string; password: string; displayName: string };
|
||||
type SessionDataDto = { userId: string; email: string; displayName: string; token: string };
|
||||
|
||||
/**
|
||||
* Auth Service
|
||||
@@ -19,9 +19,10 @@ export class AuthService {
|
||||
/**
|
||||
* Sign up a new user
|
||||
*/
|
||||
async signup(params: SignupParamsDto): Promise<SessionDataDto> {
|
||||
async signup(params: SignupParamsDto): Promise<SessionViewModel> {
|
||||
try {
|
||||
return await this.apiClient.signup(params);
|
||||
const dto = await this.apiClient.signup(params);
|
||||
return new SessionViewModel(dto.user);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
@@ -30,9 +31,10 @@ export class AuthService {
|
||||
/**
|
||||
* Log in an existing user
|
||||
*/
|
||||
async login(params: LoginParamsDto): Promise<SessionDataDto> {
|
||||
async login(params: LoginParamsDto): Promise<SessionViewModel> {
|
||||
try {
|
||||
return await this.apiClient.login(params);
|
||||
const dto = await this.apiClient.login(params);
|
||||
return new SessionViewModel(dto.user);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user