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

add try catch if call to grist fails #286

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ module.exports.extractEmailDomain = function(email) {

// Vérification si l'adresse email est valide
if (!emailRegex.test(email)) {
throw new Error("Adresse email invalide");
return undefined
}

// Extraction du domaine avec un split
Expand Down
40 changes: 0 additions & 40 deletions lib/format.test.js

This file was deleted.

6 changes: 3 additions & 3 deletions lib/oidcAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,12 @@ module.exports.finishAuth = async (req) => {
try {
const domain = format.extractEmailDomain(email)
const whitelistedDomains = await getWhitelistedDomains()
if(!whitelistedDomains.includes(domain)){
throw new Error(`The domain ${domain} is not whitelisted.`)
if(!domain || !whitelistedDomains.includes(domain)){
console.error(`The domain ${domain} is not whitelisted.`)
return { error: `L'adresse e-mail ${email} n'est pas autorisée à utiliser ce service. Si vous êtes agent de l'État, contactez-nous à [email protected]` }
}
} catch(e){
console.error(`error when validating email ${email}`,e)
return { error: `L'adresse e-mail ${email} n'est pas autorisée à utiliser ce service. Si vous êtes agent de l'État, contactez-nous à [email protected]` }
}

const user = {id_token: tokenSet.id_token, state: request.state}
Expand Down
Loading