mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 21:23:45 -05:00
Error handling when missing SAML data
When logging in and linking, if session data is missing show a more specific error message. GitOrigin-RevId: 32d733f7478180bcce18e1f466ae10255c763997
This commit is contained in:
parent
f6d70de1aa
commit
7c533fa5fb
3 changed files with 25 additions and 1 deletions
|
@ -44,6 +44,13 @@ module.exports = ErrorController = {
|
|||
logger.warn({ err: error, url: req.url }, 'invalid name error')
|
||||
res.status(400)
|
||||
res.send(error.message)
|
||||
} else if (error instanceof Errors.SAMLSessionDataMissing) {
|
||||
logger.warn(
|
||||
{ err: error, url: req.url },
|
||||
'missing SAML session data error'
|
||||
)
|
||||
res.status(400)
|
||||
res.send({ accountLinkingError: error.message })
|
||||
} else {
|
||||
logger.error(
|
||||
{ err: error, url: req.url, method: req.method, user },
|
||||
|
|
|
@ -64,6 +64,16 @@ class SAMLIdentityExistsError extends BackwardCompatibleError {
|
|||
}
|
||||
}
|
||||
|
||||
class SAMLSessionDataMissing extends BackwardCompatibleError {
|
||||
constructor(arg) {
|
||||
super(arg)
|
||||
if (!this.message) {
|
||||
this.message =
|
||||
'Please resubmit your institutional email.<br/><a href="/institutional-login">institutional login</a>'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SAMLUserNotFoundError extends BackwardCompatibleError {
|
||||
constructor(arg) {
|
||||
super(arg)
|
||||
|
@ -119,6 +129,7 @@ module.exports = {
|
|||
InvalidError,
|
||||
NotInV2Error,
|
||||
SAMLIdentityExistsError,
|
||||
SAMLSessionDataMissing,
|
||||
SAMLUserNotFoundError,
|
||||
SLInV2Error,
|
||||
ThirdPartyIdentityExistsError,
|
||||
|
|
|
@ -108,7 +108,13 @@ define(['base', 'libs/passfield'], function(App) {
|
|||
return
|
||||
}
|
||||
|
||||
if (status === 400) {
|
||||
if (status === 400 && data.accountLinkingError) {
|
||||
// Bad Request for account linking
|
||||
response.message = {
|
||||
text: data.accountLinkingError,
|
||||
type: 'error'
|
||||
}
|
||||
} else if (status === 400) {
|
||||
// Bad Request
|
||||
response.message = {
|
||||
text: 'Invalid Request. Please correct the data and try again.',
|
||||
|
|
Loading…
Reference in a new issue