Skip to content

Commit ea201e2

Browse files
authored
Merge pull request #191 from BuckinghamAJ/dev
Fixing silly mistake with sequelize
2 parents e612858 + 872006d commit ea201e2

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

server/routes/auth.routes.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const path = require("path");
66
//const util = require('node:util');
77
const {jsonToURI} = require('../utilities.js');
88

9-
9+
const { Op } = require('sequelize');
1010
const logger = require('../config/winston')
1111
// noinspection JSUnresolvedVariable
1212
const User = require('../models').User
@@ -290,20 +290,28 @@ async function createOrUpdateLoginGovUser(login_gov_data) {
290290
let u = await User.findOne({
291291
where: {
292292
[Op.or]: [
293-
{ email: login_gov_data.email },
294-
{ email: { [Op.in]: login_gov_data.all_emails || [] } }
293+
{ 'email': login_gov_data.email },
294+
{ 'email': { [Op.in]: login_gov_data.all_emails || [] } }
295295
]
296296
}
297297
});
298298

299+
logger.log("info", "User found in DB", {user: u, tag: "createOrUpdateLoginGovUser"})
300+
299301
if (u) {
300302
return updateUser(login_gov_data, u)
301303
} else {
302304
return createUser(login_gov_data)
303305
}
304306

305307
} catch (e) {
306-
logger.log("error", "Error caught in create/update MAX User", {error: e, tag: "create/update MAX User"})
308+
309+
logger.log("error", "Error caught in create/update Login.gov User", {error: e.message, tag: "create/update Login.gov User"})
310+
311+
return res.status(302)
312+
.set('Location', encodeURI(config['srtClientUrl'] + '/auth' + '?error=Database Error creating user account. Please contact srt@gsa.gov.')) // send them back with no token
313+
.send(`<html lang="en"><body>Login Failed</body></html>`)
314+
307315
}
308316
}
309317

@@ -702,6 +710,7 @@ module.exports = {
702710
mapCASRoleToUserRole : mapCASRoleToUserRole,
703711
roleNameToCASGroup : roleNameToCASGroup,
704712
createOrUpdateMAXUser: createOrUpdateMAXUser,
713+
createOrUpdateLoginGovUser: createOrUpdateLoginGovUser,
705714
userInfoFromReq : userInfoFromReq,
706715
isGSAAdmin : isGSAAdmin,
707716
passwordOnlyWhitelist: userOnPasswordOnlyWhitelist,

0 commit comments

Comments
 (0)