Skip to content

Commit

Permalink
feat: auth url params
Browse files Browse the repository at this point in the history
  • Loading branch information
peterphanouvong committed Feb 1, 2024
1 parent 543fa35 commit ed46bf6
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 15 deletions.
1 change: 0 additions & 1 deletion src/handlers/pageRouter/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {prepareForRedirect} from '../../utils/pageRouter/prepareForRedirect';

export const login = async (req, res) => {
const options = req.query;
const {org_code, is_create_org, org_name = ''} = options;

const authUrl = prepareForRedirect(options, 'login', res);

Expand Down
2 changes: 0 additions & 2 deletions src/handlers/pageRouter/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import {prepareForRedirect} from '../../utils/pageRouter/prepareForRedirect';

export const register = async (req, res) => {
const options = req.query;
const {org_code, is_create_org, org_name = ''} = options;

const authUrl = prepareForRedirect(options, 'register', res);

res.redirect(authUrl);
Expand Down
15 changes: 3 additions & 12 deletions src/utils/generateAuthUrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {config} from '../config/index';
import {generateCallbackUrl} from '../utils/generateCallbackUrl';

export function generateAuthUrl(options, type = 'login') {
const {org_code, is_create_org, org_name = ''} = options;
const authUrl = new URL(config.issuerURL + config.issuerRoutes[type]);

let searchParams = {
Expand All @@ -22,17 +21,9 @@ export function generateAuthUrl(options, type = 'login') {
searchParams.start_page = 'registration';
}

if (org_code) {
searchParams.org_code = org_code;
}

if (is_create_org) {
searchParams.is_create_org = is_create_org;
searchParams.org_name = org_name;
}

if (config.audience) {
searchParams.audience = config.audience;
for (const [key, value] of Object.entries(options)) {
if (key === 'kindeAuth') continue;
searchParams[key] = value;
}

authUrl.search = new URLSearchParams(searchParams);
Expand Down

0 comments on commit ed46bf6

Please sign in to comment.