Skip to content

Commit

Permalink
refactor: merge handleOAuthLogin
Browse files Browse the repository at this point in the history
  • Loading branch information
risv1 committed Mar 2, 2024
1 parent 572d369 commit fecee8b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 21 deletions.
4 changes: 2 additions & 2 deletions apps/api/src/auth/controller/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export class AuthController {
const { emails, displayName: name, photos } = req.user
const email = emails[0].value
const profilePictureUrl = photos[0].value
return await this.authService.handleGithubOAuth(
return await this.authService.handleOAuthLogin(
email,
name,
profilePictureUrl
Expand Down Expand Up @@ -178,7 +178,7 @@ export class AuthController {
const { emails, displayName: name, photos } = req.user
const email = emails[0].value
const profilePictureUrl = photos[0].value
return await this.authService.handleGoogleOAuth(
return await this.authService.handleOAuthLogin(
email,
name,
profilePictureUrl
Expand Down
20 changes: 1 addition & 19 deletions apps/api/src/auth/service/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export class AuthService {
}

/* istanbul ignore next */
async handleGithubOAuth(
async handleOAuthLogin(
email: string,
name: string,
profilePictureUrl: string
Expand All @@ -131,24 +131,6 @@ export class AuthService {
}
}

/* istanbul ignore next */
async handleGoogleOAuth(
email: string,
name: string,
profilePictureUrl: string
) {
const user = await this.createUserIfNotExists(
email,
name,
profilePictureUrl
)
const token = await this.generateToken(user.id)
return {
...user,
token
}
}

/* istanbul ignore next */
@Cron(CronExpression.EVERY_HOUR)
async cleanUpExpiredOtps() {
Expand Down

0 comments on commit fecee8b

Please sign in to comment.