Onboarding
This commit is contained in:
@@ -193,6 +193,35 @@ export class AuthService {
|
||||
return user.name || user.email;
|
||||
}
|
||||
|
||||
async getPublicUser(userId: string): Promise<PublicUser> {
|
||||
const user = await this.usersRepository.findOne({
|
||||
where: { id: userId },
|
||||
});
|
||||
|
||||
if (!user) {
|
||||
throw new UnauthorizedException('Authenticated user is required.');
|
||||
}
|
||||
|
||||
return this.toPublicUser(user);
|
||||
}
|
||||
|
||||
async updateOnboardingCompleted(
|
||||
userId: string,
|
||||
completed: boolean,
|
||||
): Promise<PublicUser> {
|
||||
const user = await this.usersRepository.findOne({
|
||||
where: { id: userId },
|
||||
});
|
||||
|
||||
if (!user) {
|
||||
throw new UnauthorizedException('Authenticated user is required.');
|
||||
}
|
||||
|
||||
user.onboardingCompleted = completed;
|
||||
|
||||
return this.toPublicUser(await this.usersRepository.save(user));
|
||||
}
|
||||
|
||||
private normalizeEmail(email?: string): string {
|
||||
const normalizedEmail = email?.trim().toLowerCase();
|
||||
|
||||
@@ -328,6 +357,7 @@ export class AuthService {
|
||||
email: user.email,
|
||||
name: user.name ?? undefined,
|
||||
verified: user.verified,
|
||||
onboardingCompleted: user.onboardingCompleted === true,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user