Skip to content

Commit

Permalink
feat: onlyCreateInvited option is not applied on coreIdProviders
Browse files Browse the repository at this point in the history
  • Loading branch information
albanm committed Dec 13, 2024
1 parent bf9a0da commit 4135e17
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions server/routers/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -831,9 +831,12 @@ const oauthCallback = asyncWrap(async (req, res, next) => {
let user = await storage.getUserByEmail(userInfo.user.email, req.site)
logContext.user = user

if (!user && !invit && config.onlyCreateInvited) {
if (!user && !invit && config.onlyCreateInvited && !provider.coreIdProvider) {
return returnError('onlyCreateInvited', 400)
}
if (!user && storage.readonly) {
return returnError('userUnknown', 403)
}

// Re-create a user that was never validated.. first clean temporary user
if (user && user.emailConfirmed === false) {
Expand All @@ -851,10 +854,6 @@ const oauthCallback = asyncWrap(async (req, res, next) => {
if (invit && memberInfo.create) throw new Error('Cannot create a member from a identity provider and accept an invitation at the same time')

if (!user) {
if ((!invit && config.onlyCreateInvited) || storage.readonly) {
return returnError('userUnknown', 403)
}

if (provider.coreIdProvider) {
oauthInfo.coreId = true
userInfo.user.coreIdProvider = { type: provider.type || 'oauth', id: provider.id }
Expand Down

0 comments on commit 4135e17

Please sign in to comment.