Skip to content

Commit

Permalink
ISSUE #5412 createTEamspace now assign admin role to user
Browse files Browse the repository at this point in the history
  • Loading branch information
carmenfan committed Mar 2, 2025
1 parent 26e4253 commit 1da40bc
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 18 deletions.
2 changes: 1 addition & 1 deletion backend/src/v5/middleware/sso/frontegg.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ const redirectForAuth = (redirectURL) => async (req, res) => {
codeChallenge: req.session.pkceCodes.challenge,
};

const link = generateAuthenticationCodeUrl(req.authParams, accountId);
const link = await generateAuthenticationCodeUrl(req.authParams, accountId);
respond(req, res, templates.ok, { link });
} catch (err) {
respond(req, res, err);
Expand Down
2 changes: 1 addition & 1 deletion backend/src/v5/processors/teamspaces/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Teamspaces.initTeamspace = async (teamspaceName, owner) => {
]);
await Promise.all([
createTeamspaceSettings(teamspaceName, teamspaceId),
assignUserToJob(teamspaceName, DEFAULT_OWNER_JOB, teamspaceName),
assignUserToJob(teamspaceName, DEFAULT_OWNER_JOB, owner),
addDefaultTemplates(teamspaceName),
]);
await Promise.all([
Expand Down
12 changes: 6 additions & 6 deletions backend/src/v5/services/sso/frontegg/components/accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const Accounts = {};

Accounts.getTeamspaceByAccount = async (accountId) => {
try {
const config = getConfig();
const config = await getConfig();
const { data: { metadata } } = await get(`${config.vendorDomain}/tenants/resources/tenants/v2/${accountId}`, await getBearerHeader());
const metaJson = JSON.parse(metadata);
return metaJson[META_LABEL_TEAMSPACE];
Expand All @@ -36,7 +36,7 @@ Accounts.getTeamspaceByAccount = async (accountId) => {

Accounts.createAccount = async (name) => {
try {
const config = getConfig();
const config = await getConfig();
const payload = {
tenantId: generateUUIDString(),
name,
Expand Down Expand Up @@ -70,7 +70,7 @@ Accounts.createAccount = async (name) => {

Accounts.getAllUsersInAccount = async (accountId) => {
try {
const config = getConfig();
const config = await getConfig();
const header = {
...await getBearerHeader(),
'frontegg-tenant-id': accountId,
Expand Down Expand Up @@ -107,7 +107,7 @@ Accounts.getAllUsersInAccount = async (accountId) => {

Accounts.addUserToAccount = async (accountId, userId, sendInvite = true) => {
try {
const config = getConfig();
const config = await getConfig();
const payload = {
tenantId: accountId,
validateTenantExist: true,
Expand All @@ -122,7 +122,7 @@ Accounts.addUserToAccount = async (accountId, userId, sendInvite = true) => {

Accounts.removeUserFromAccount = async (accountId, userId) => {
try {
const config = getConfig();
const config = await getConfig();
const headers = {
...await getBearerHeader(),
[HEADER_TENANT_ID]: accountId,
Expand All @@ -137,7 +137,7 @@ Accounts.removeUserFromAccount = async (accountId, userId) => {

Accounts.removeAccount = async (accountId) => {
try {
const config = getConfig();
const config = await getConfig();
await httpDelete(`${config.vendorDomain}/tenants/resources/tenants/v1/${accountId}`, await getBearerHeader());
} catch (err) {
logger.logError(`Failed to remove account: ${JSON.stringify(err?.response?.data)} `);
Expand Down
6 changes: 3 additions & 3 deletions backend/src/v5/services/sso/frontegg/components/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ Auth.validateToken = async ({ token }, userId) => {
}
};

Auth.generateAuthenticationCodeUrl = ({ state, redirectURL, codeChallenge }, tenantId) => {
const config = getConfig();
Auth.generateAuthenticationCodeUrl = async ({ state, redirectURL, codeChallenge }, tenantId) => {
const config = await getConfig();
const qsObj = deleteIfUndefined({
response_type: 'code',
scope: 'openId',
Expand All @@ -60,7 +60,7 @@ Auth.generateAuthenticationCodeUrl = ({ state, redirectURL, codeChallenge }, ten
};

Auth.generateToken = async (urlUsed, code, challenge) => {
const config = getConfig();
const config = await getConfig();
const payload = {
grant_type: 'authorization_code',
code,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,8 @@ const init = async () => {
}
};

Connection.getConfig = () => {
if (!config) {
throw new Error('Cannot get config before initialising');
}

Connection.getConfig = async () => {
await init();
return config;
};

Expand Down
4 changes: 2 additions & 2 deletions backend/src/v5/services/sso/frontegg/components/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const Users = {};

Users.getUserById = async (userId) => {
try {
const config = getConfig();
const config = await getConfig();
const { data } = await get(`${config.vendorDomain}/identity/resources/vendor-only/users/v1/${userId}`, await getBearerHeader());
return data;
} catch (err) {
Expand All @@ -33,7 +33,7 @@ Users.getUserById = async (userId) => {

Users.createUser = async (accountId, email, name, userData, privateUserData, bypassVerification = false) => {
try {
const config = getConfig();
const config = await getConfig();
const payload = deleteIfUndefined({
email,
name,
Expand Down

0 comments on commit 1da40bc

Please sign in to comment.