111 refactor google auth to delete authentication if already exists#287
Open
111 refactor google auth to delete authentication if already exists#287
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds Google OAuth support by introducing a GoogleProvider for token management, integrates token revocation into the authentication flow, and renames the standard provider class.
- Define a shared
Credentialsinterface and relocateAUTH_COOKIE_NAMEto the schemas module. - Implement
GoogleProvider(token fetch/revoke) and invoke revocation inAuthDataService#createAuth. - Rename
StandardSecuritytoStandardProviderand update related imports/tests.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/shared/src/types/auth.ts | Added Credentials interface; removed old cookie constant. |
| packages/shared/src/schemas/auth.ts | Added AUTH_COOKIE_NAME constant. |
| apps/backend/src/data-layer/services/AuthDataService.ts | Integrated token revocation when existing auth is detected. |
| apps/backend/src/business-layer/provider/standard.ts | Renamed StandardSecurity to StandardProvider. |
| apps/backend/src/business-layer/provider/standard.test.ts | Updated tests to use StandardProvider. |
| apps/backend/src/business-layer/provider/google.ts | Introduced GoogleProvider with fetchTokens and revokeToken. |
| apps/backend/src/app/api/auth/google/callback/route.ts | Switched to GoogleProvider.fetchTokens; cleaned up token logic. |
Comments suppressed due to low confidence (3)
apps/backend/src/data-layer/services/AuthDataService.ts:13
- The JSDoc above still states this method returns an
Authenticationdocument, but the signature now allowsundefined; update the comment or ensure the method always returns a value.
public async createAuth(newAuth: CreateAuthenticationData): Promise<Authentication | undefined> {
apps/backend/src/business-layer/provider/google.ts:26
- [nitpick] Consider adding unit tests for
fetchTokensandrevokeTokento validate token handling and error paths.
static async fetchTokens(code: string): Promise<Credentials | undefined> {
packages/shared/src/schemas/auth.ts:101
- Duplicated definition of AUTH_COOKIE_NAME in different modules can lead to inconsistencies; consider centralizing this constant in one shared location.
export const AUTH_COOKIE_NAME = "auth_token"
taroj1205
reviewed
Jun 6, 2025
jji05
reviewed
Jun 29, 2025
Comment on lines
+41
to
+42
| const usersToCreate = [casualUserMock, memberUserMock, adminUserMock] | ||
| await Promise.all( | ||
| usersToCreate.map((user) => | ||
| payload.create({ | ||
| collection: "user", | ||
| data: user, | ||
| }), | ||
| ), | ||
| ) | ||
| await Promise.all(usersToCreate.map(new UserDataService().createUser)) |
Member
There was a problem hiding this comment.
just a note, i'm reverting this because it doesn't properly set the IDs, UserDataService.createUser omits the id
Contributor
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Authenticationcollection is createdGoogleProviderclass to handle token managementStandardSecuritytoStandardProviderFixes #111
Type of change
How Has This Been Tested?
Checklist before requesting a review