decent place with fixing api and such
This commit is contained in:
@@ -12,14 +12,24 @@ export class UserService {
|
||||
}
|
||||
|
||||
static async createUserIfNotExists(newUser: User) {
|
||||
return await collections.users?.insertOne(newUser);
|
||||
const exists = (await collections.users?.findOne({ email: newUser.email }))
|
||||
?._id;
|
||||
|
||||
if (!exists) {
|
||||
return await collections.users?.insertOne(newUser);
|
||||
}
|
||||
|
||||
// user with email exists already, don't create
|
||||
return null;
|
||||
}
|
||||
|
||||
static async getGoogleUserInfoWithAccessToken(
|
||||
accessToken: string
|
||||
): Promise<GoogleUserInfo> {
|
||||
return await axios.get(
|
||||
`https://www.googleapis.com/oauth2/v1/userinfo?access_token=${accessToken}`
|
||||
);
|
||||
return (
|
||||
await axios.get(
|
||||
`https://www.googleapis.com/oauth2/v1/userinfo?access_token=${accessToken}`
|
||||
)
|
||||
).data;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user