Skip to content

Commit

Permalink
merging develop
Browse files Browse the repository at this point in the history
  • Loading branch information
hsb1007 committed Jun 12, 2024
2 parents da66894 + 85a0b33 commit af6f657
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM node:20-alpine AS base
FROM base as build

WORKDIR /app

RUN apk add --no-cache git
RUN npm i -g pnpm

COPY package.json .
Expand Down
4 changes: 2 additions & 2 deletions fly.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ primary_region = "syd"
[http_service]
internal_port = 4200
force_https = true
auto_stop_machines = true
auto_start_machines = true
auto_stop_machines = false
auto_start_machines = false
min_machines_running = 0
[http_service.concurrency]
type = "requests"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"passport-facebook": "^3.0.0",
"passport-github2": "^0.1.12",
"passport-google-oauth20": "^2.0.0",
"passport-linkedin-oauth2": "^2.0.0",
"passport-linkedin-oauth2": "github:auth0/passport-linkedin-oauth2",
"prisma": "^5.10.2",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.8.1",
Expand Down
12 changes: 7 additions & 5 deletions pnpm-lock.yaml

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

17 changes: 5 additions & 12 deletions src/auth/service/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,7 @@ export class AuthService {
}

async handleLinkedInOAuthLogin(req: any) {
const { emails, name, photos } = req.user;
const email = emails[0].value;
const displayName = name.givenName + ' ' + name.familyName;
const profilePictureUrl = photos[0].value;

const { email, displayName, picture } = req.user;
const socialAccount = await this.prisma.socialAccount.findFirst({
where: {
socialId: req.user.socialId,
Expand All @@ -140,7 +136,7 @@ export class AuthService {
email,
AuthType.LINKEDIN,
displayName,
profilePictureUrl,
picture,
false,
);
await this.connectSocialPlatform(
Expand Down Expand Up @@ -217,9 +213,6 @@ export class AuthService {
throw new NotFoundException('User not found');
}

if (user.isEmailVerified) {
throw new BadRequestException('Email already verified');
}
await this.sendEmailVerificationCode(email);
}

Expand Down Expand Up @@ -283,6 +276,7 @@ export class AuthService {
throwErrorIfUserExists?: boolean,
) {
email = email.toLowerCase();

let user = await this.findUserByEmail(email);
if (user && throwErrorIfUserExists) {
throw new ConflictException('User already exists');
Expand Down Expand Up @@ -390,7 +384,6 @@ export class AuthService {
userId: string,
req: any,
) {
console.log(platform, userId, req.user);

const socialAcc = await this.prisma.socialAccount.findMany({
where: { socialId: req.user.id, platform },
Expand All @@ -411,9 +404,9 @@ export class AuthService {
? `${req.user._json.first_name} ${req.user._json.last_name}`
: req.user._json.login),
email: req.user.emails?.[0]?.value || req.user._json.email,
socialId: req.user.id,
socialId: req.user.id || req.user._json.sub,
profileUrl: req.user.profileUrl,
pictureUrl: req.user.photos[0].value,
pictureUrl: req.user.photos?.[0]?.value || req.user.picture,
userId,
},
});
Expand Down

0 comments on commit af6f657

Please sign in to comment.