Skip to content

Commit

Permalink
Merge pull request #1 from mir-ishfaq-hussain/mir-ishfaq-hussain-patch-1
Browse files Browse the repository at this point in the history
Update user.service.ts
  • Loading branch information
mir-ishfaq-hussain committed Jan 16, 2024
2 parents cd371fc + 042361d commit d1e35d2
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions packages/hoppscotch-backend/src/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,8 @@ export class UserService {

return {
...dbUser,
currentRESTSession: dbCurrentRESTSession
? JSON.stringify(dbCurrentRESTSession)
: null,
currentGQLSession: dbCurrentGQLSession
? JSON.stringify(dbCurrentGQLSession)
: null,
currentRESTSession: JSON.stringify(dbCurrentRESTSession) ?? null,
currentGQLSession: JSON.stringify(dbCurrentGQLSession) ?? null,
};
}

Expand Down Expand Up @@ -147,8 +143,8 @@ export class UserService {
refreshTokenSSO: string,
profile,
) {
const userDisplayName = !profile.displayName ? null : profile.displayName;
const userPhotoURL = !profile.photos ? null : profile.photos[0].value;
const userDisplayName = profile?.displayName ?? null;
const userPhotoURL = profile?.photos?.[0]?.value ?? null;

const createdUser = await this.prisma.user.create({
data: {
Expand Down Expand Up @@ -188,8 +184,8 @@ export class UserService {
data: {
provider: profile.provider,
providerAccountId: profile.id,
providerRefreshToken: refreshToken ? refreshToken : null,
providerAccessToken: accessToken ? accessToken : null,
providerRefreshToken: refreshToken ??? null,
providerAccessToken: accessToken ?? null,
user: {
connect: {
uid: user.uid,
Expand All @@ -215,8 +211,8 @@ export class UserService {
uid: user.uid,
},
data: {
displayName: !profile.displayName ? null : profile.displayName,
photoURL: !profile.photos ? null : profile.photos[0].value,
displayName: profile?.displayName ?? null,
photoURL: profile?.photos[0]?.value ?? null,
},
});
return E.right(updatedUser);
Expand Down

0 comments on commit d1e35d2

Please sign in to comment.