Skip to content

Commit

Permalink
feat: make google auth work with expo app (#91)
Browse files Browse the repository at this point in the history
* Make google auth work with expo app

* add github login

* send expo friendly responses

* fix tests
  • Loading branch information
adelinaenache authored Jun 4, 2024
1 parent 2ce6233 commit e2acc45
Show file tree
Hide file tree
Showing 13 changed files with 246 additions and 14 deletions.
9 changes: 8 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ FLY_ACCESS_TOKEN=
DATABASE_URL=postgresql://postgres:[email protected]:5432/culero
JWT_SECRET=secret

GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
GITHUB_CALLBACK_URL=http://localhost:4200/api/auth/github/callback


SMTP_HOST=
SMTP_PORT=
SMTP_EMAIL_ADDRESS=
Expand All @@ -44,4 +49,6 @@ PROFILES_DIRECTORY=
REDIS_URL=redis://localhost:6379

LINKEDIN_PROFILE_FETCHER_API_KEY=
LINKEDIN_PROFILE_FETCHER_HOST=
LINKEDIN_PROFILE_FETCHER_HOST=\

SESSION_SECRET=
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@
"crypto-js": "^4.2.0",
"expo-server-sdk": "^3.10.0",
"express": "^4.19.2",
"express-session": "^1.18.0",
"install": "^0.13.0",
"ioredis": "^5.4.1",
"jest-mock-extended": "^3.0.5",
"nodemailer": "^6.9.12",
"passport-facebook": "^3.0.0",
"passport-github2": "^0.1.12",
"passport-google-oauth20": "^2.0.0",
"passport-linkedin-oauth2": "^2.0.0",
"prisma": "^5.10.2",
Expand Down
56 changes: 56 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/auth/auth.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { LinkedInStrategy } from '../oauth/strategy/linkedin/linkedin.strategy';
import { AppleOAuthStrategyFactory } from '../oauth/factory/apple/apple-strategy.factory';
import { AppleStrategy } from '../oauth/strategy/apple/apple.strategy';
import { MailService } from '../mail/mail.service';
import { GithubOAuthStrategyFactory } from '../oauth/factory/github/github-strategy.factory';
import { GithubStrategy } from '../oauth/strategy/github/github.strategy';

@Module({
imports: [
Expand Down Expand Up @@ -64,6 +66,14 @@ import { MailService } from '../mail/mail.service';
},
inject: [AppleOAuthStrategyFactory],
},
GithubOAuthStrategyFactory,
{
provide: GithubStrategy,
useFactory: (githubOAuthFactory: GithubOAuthStrategyFactory) => {
githubOAuthFactory.createOAuthStrategy();
},
inject: [GithubOAuthStrategyFactory],
},
],
})
export class AuthModule {}
2 changes: 2 additions & 0 deletions src/auth/controller/auth.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { AppleOAuthStrategyFactory } from '../../oauth/factory/apple/apple-strat
import { ConfigService } from '@nestjs/config';
import { MailService } from '../../mail/mail.service';
import { mockDeep } from 'jest-mock-extended';
import { GithubOAuthStrategyFactory } from '../../oauth/factory/github/github-strategy.factory';

describe('AuthController', () => {
let controller: AuthController;
Expand All @@ -25,6 +26,7 @@ describe('AuthController', () => {
LinkedInOAuthStrategyFactory,
FacebookOAuthStrategyFactory,
AppleOAuthStrategyFactory,
GithubOAuthStrategyFactory,
ConfigService,
MailService,
],
Expand Down
Loading

0 comments on commit e2acc45

Please sign in to comment.