mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-21 03:13:42 +00:00
Render account linking page
Simplify account linking data. Change `institution.name` to `institutionName` Update emailAlreadyLinked value. The layout checks for 'primary' and 'secondary', not a boolean, so update data passed Add error messages to Account Linking pages Rename account linking file name to reflect route change. Changed `institution` to `institutional` on the login route. GitOrigin-RevId: 4e12b9ec7c1577efbaa8c0628e3c41c70114844e
This commit is contained in:
parent
abae7ef2a3
commit
4defd2b6b5
2 changed files with 43 additions and 0 deletions
|
@ -54,6 +54,15 @@ class NotInV2Error extends BackwardCompatibleError {}
|
|||
|
||||
class SLInV2Error extends BackwardCompatibleError {}
|
||||
|
||||
class SAMLUserNotFoundError extends BackwardCompatibleError {
|
||||
constructor(arg) {
|
||||
super(arg)
|
||||
if (!this.message) {
|
||||
this.message = 'user not found for SAML provider and external id'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ThirdPartyIdentityExistsError extends BackwardCompatibleError {
|
||||
constructor(arg) {
|
||||
super(arg)
|
||||
|
@ -99,6 +108,7 @@ module.exports = {
|
|||
EmailExistsError,
|
||||
InvalidError,
|
||||
NotInV2Error,
|
||||
SAMLUserNotFoundError,
|
||||
SLInV2Error,
|
||||
ThirdPartyIdentityExistsError,
|
||||
ThirdPartyUserNotFoundError,
|
||||
|
|
33
services/web/app/src/Features/User/SAMLIdentityManager.js
Normal file
33
services/web/app/src/Features/User/SAMLIdentityManager.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
const Errors = require('../Errors/Errors')
|
||||
const { User } = require('../../models/User')
|
||||
|
||||
async function getUser(providerId, externalUserId) {
|
||||
if (providerId == null || externalUserId == null) {
|
||||
throw new Error('invalid arguments')
|
||||
}
|
||||
try {
|
||||
const query = SAMLIdentityManager._getUserQuery(providerId, externalUserId)
|
||||
let user = await User.findOne(query).exec()
|
||||
if (!user) {
|
||||
throw new Errors.SAMLUserNotFoundError()
|
||||
}
|
||||
return user
|
||||
} catch (error) {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const SAMLIdentityManager = {
|
||||
_getUserQuery(providerId, externalUserId) {
|
||||
externalUserId = externalUserId.toString()
|
||||
providerId = providerId.toString()
|
||||
const query = {
|
||||
'samlIdentifiers.externalUserId': externalUserId,
|
||||
'samlIdentifiers.providerId': providerId
|
||||
}
|
||||
return query
|
||||
},
|
||||
getUser
|
||||
}
|
||||
|
||||
module.exports = SAMLIdentityManager
|
Loading…
Add table
Reference in a new issue