Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simple changes for assigning null values #3752

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
20 changes: 8 additions & 12 deletions packages/hoppscotch-backend/src/user/user.service.ts
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,
mir-ishfaq-hussain marked this conversation as resolved.
Show resolved Hide resolved
};
}

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