Skip to content

Commit

Permalink
Improve SSO login flow
Browse files Browse the repository at this point in the history
  • Loading branch information
flvndvd committed Mar 7, 2024
1 parent 851f4ef commit db3f417
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions front/pages/api/auth/[auth0].ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
import { handleAuth, handleLogin } from "@auth0/nextjs-auth0";
import type { AuthorizationParameters } from "@auth0/nextjs-auth0/dist/auth0-session";

export default handleAuth({
login: handleLogin({
authorizationParams: {
login: handleLogin((req) => {
const connection = "query" in req ? req.query.connection : undefined;

const defaultAuthorizationParams: Partial<AuthorizationParameters> = {
scope: "openid profile email",
},
};

// Set the Auth0 connection based on the provided connection param, redirecting the user to the correct screen.
if (connection) {
defaultAuthorizationParams.connection = connection;
}

return {
authorizationParams: defaultAuthorizationParams,
};
}),
});

0 comments on commit db3f417

Please sign in to comment.