Skip to content

Commit

Permalink
Replace legacy url Node module with new URL API, bringing it in-line …
Browse files Browse the repository at this point in the history
…with the Quickstart
  • Loading branch information
albertoperdomo committed Oct 27, 2023
1 parent 316100c commit 2002715
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const hash = require("pbkdf2-password")();
const path = require("path");
const session = require("express-session");
const jwt = require("jsonwebtoken");
const url = require("url");

var app = (module.exports = express());

Expand Down Expand Up @@ -189,15 +188,11 @@ app.post("/login", function (req, res, next) {
});

app.get("/sso/metabase", restrict, (req, res) => {
res.redirect(
url.format({
pathname: `${METABASE_SITE_URL}/auth/sso`,
query: {
jwt: signUserToken(req.session.user),
return_to: `${req.query.return_to || "/"}?${mods}`,
},
})
);
const ssoUrl = new URL("/auth/sso", METABASE_SITE_URL);
ssoUrl.searchParams.set("jwt", signUserToken(req.session.user));
ssoUrl.searchParams.set("return_to", `${req.query.return_to ?? "/"}?${mods}`);

res.redirect(ssoUrl);
});

const PORT = 8080;
Expand Down

0 comments on commit 2002715

Please sign in to comment.