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

Address OAuth issues found in prod #211

Merged
merged 2 commits into from
Dec 19, 2023
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 src/controllers/getOauth.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module.exports = {
client_secret: context.config.GH_CLIENTSECRET
});

const accessToken = iniitalAuth.body?.access_token;
const accessToken = initialAuth.body?.access_token;

if (accessToken === null || initialAuth.body?.token_type === null) {
res.status(500).json({
Expand Down
23 changes: 16 additions & 7 deletions src/setupEndpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,22 @@ const endpointHandler = async function(node, req, res) {

let obj;

if (node.endpoint.endpointKind === "raw") {
await node.logic(req, res, context);
// If it's a raw endpoint, they must handle all other steps manually
return;

} else {
obj = await node.logic(params, context);
try {
if (node.endpoint.endpointKind === "raw") {
await node.logic(req, res, context);
// If it's a raw endpoint, they must handle all other steps manually
return;

} else {
obj = await node.logic(params, context);
}
} catch(err) {
// The main logic request has failed. We will generate our own return obj,
// and exit.
obj = new context.sso();
obj.notOk().addContent(err)
.addMessage("An unexpected error has occurred.")
.addShort("server_error");
}

if (typeof node.postLogic === "function") {
Expand Down