Skip to content

Commit b8169df

Browse files
committed
Ease constraint on empty displayname
1 parent 91a48a0 commit b8169df

File tree

2 files changed

+13
-3
lines changed
  • packages
    • todo0/src/server/controllers
    • wiki0/src/server/controllers

2 files changed

+13
-3
lines changed

packages/todo0/src/server/controllers/oidc.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,13 @@ const verify = async (
7474
}
7575

7676
// Ensure the profile response has the correct fields present to update or create a new user
77-
if (!profile.displayName || !profile.emails) {
78-
return done(new Error(`Invalid profile response: ${JSON.stringify(profile)}`));
77+
if (!profile.emails) {
78+
done(new Error(`Invalid profile response: ${JSON.stringify(profile)}`));
79+
return;
80+
}
81+
82+
if (!profile.displayName) {
83+
profile.displayName = profile.emails[0]?.value || ""
7984
}
8085

8186
try {

packages/wiki0/src/server/controllers/oidc.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,16 @@ const verify = async (
7373

7474
if (!user) {
7575
// Ensure the profile response has the correct fields present to update or create a new user
76-
if (!profile.displayName || !profile.emails) {
76+
77+
if (!profile.emails) {
7778
done(new Error(`Invalid profile response: ${JSON.stringify(profile)}`));
7879
return;
7980
}
8081

82+
if (!profile.displayName) {
83+
profile.displayName = profile.emails[0]?.value || ""
84+
}
85+
8186
user = await prisma.user.findFirst({
8287
where: {
8388
orgId: org.id,

0 commit comments

Comments
 (0)