Commit 51eacdaf authored by Grant's avatar Grant
Browse files

pass errors from oidc to sentry

parent 65f9b6e4
Loading
Loading
Loading
Loading
Loading
+3 −8
Original line number Diff line number Diff line
import * as Sentry from "@sentry/node";
import { Router } from "express";
import { ResponseBodyError } from "openid-client";

@@ -79,6 +80,7 @@ app.get("/callback", RateLimiter.HIGH, async (req, res) => {
  try {
    exchange = await OpenID.exchangeToken(req.originalUrl);
  } catch (e) {
    Sentry.captureException(e);
    Logger.error(e);

    if (e instanceof ResponseBodyError) {
@@ -121,14 +123,6 @@ app.get("/callback", RateLimiter.HIGH, async (req, res) => {
    return;
  }

  if (!exchange || !exchange.access_token) {
    res.status(400).json({
      success: false,
      error: "FAILED TOKEN EXCHANGE",
    });
    return;
  }

  try {
    const whoami = await OpenID.userInfo<{
      instance: {
@@ -200,6 +194,7 @@ app.get("/callback", RateLimiter.HIGH, async (req, res) => {
    req.session.save();
    res.redirect("/");
  } catch (e) {
    Sentry.captureException(e);
    Logger.error("callback error", e);
    res
      .status(500)