feat: support google login on desktop (#4053)

Co-authored-by: Alex Yang <himself65@outlook.com>
This commit is contained in:
Peng Xiao
2023-08-31 12:51:49 +08:00
committed by GitHub
parent ba735d8b57
commit 4e45554585
14 changed files with 256 additions and 96 deletions

View File

@@ -34,7 +34,7 @@ export class AuthResolver {
@ResolveField(() => TokenType)
token(@CurrentUser() currentUser: UserType, @Parent() user: UserType) {
if (user !== currentUser) {
if (user.id !== currentUser.id) {
throw new ForbiddenException();
}

View File

@@ -83,14 +83,20 @@ export class UserResolver {
description: 'Get current user',
})
async currentUser(@CurrentUser() user: User) {
const storedUser = await this.prisma.user.findUnique({
where: { id: user.id },
});
if (!storedUser) {
throw new BadRequestException(`User ${user.id} not found in db`);
}
return {
id: user.id,
name: user.name,
email: user.email,
emailVerified: user.emailVerified,
avatarUrl: user.avatarUrl,
createdAt: user.createdAt,
hasPassword: !!user.password,
id: storedUser.id,
name: storedUser.name,
email: storedUser.email,
emailVerified: storedUser.emailVerified,
avatarUrl: storedUser.avatarUrl,
createdAt: storedUser.createdAt,
hasPassword: !!storedUser.password,
};
}