Skip to content

Commit

Permalink
fix(auth-api): The Auth API now accepts if a workspace is the default…
Browse files Browse the repository at this point in the history
… or not

The authportal has been wired up to send the correct data now so the auth-api can remove the hard coded nature of the "false"
  • Loading branch information
stack72 committed Jul 23, 2024
1 parent 93d4e24 commit f63f298
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions bin/auth-api/src/routes/workspace.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ router.post("/workspaces/new", async (ctx) => {
const reqBody = validate(ctx.request.body, z.object({
instanceUrl: z.string().url(),
displayName: z.string(),
isDefault: z.boolean(),
}));

// isDefaultWorkspace: z.boolean(),
let workspaceEnvType;
if (reqBody.instanceUrl === "https://app.systeminit.com") {
workspaceEnvType = InstanceEnvType.SI;
Expand All @@ -98,7 +98,7 @@ router.post("/workspaces/new", async (ctx) => {
workspaceEnvType,
reqBody.instanceUrl,
reqBody.displayName,
false,
reqBody.isDefault,
);

ctx.body = {
Expand Down
8 changes: 6 additions & 2 deletions bin/auth-api/src/services/users.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ export async function getUserById(id: UserId) {
});
if (!userWithTosAgreement) return null;

const agreedTosVersion = userWithTosAgreement?.TosAgreement?.[0]?.tosVersionId;
const needsTosUpdate = !agreedTosVersion || agreedTosVersion < LATEST_TOS_VERSION_ID;
const agreedTosVersion =
userWithTosAgreement?.TosAgreement?.[0]?.tosVersionId;
const needsTosUpdate =
!agreedTosVersion || agreedTosVersion < LATEST_TOS_VERSION_ID;

return {
..._.omit(userWithTosAgreement, "TosAgreement"),
Expand Down Expand Up @@ -119,6 +121,8 @@ export async function createOrUpdateUserFromAuth0Details(

// create a default saas workspace
// await createWorkspace(user, InstanceEnvType.SI, "https://app.systeminit.com", `${user.nickname}'s Production Workspace`);
// we want to check if this is the first production workspace that a user has and if so, we are going to set it as the default
// when we launch this feature!
await createWorkspace(
user,
InstanceEnvType.LOCAL,
Expand Down

0 comments on commit f63f298

Please sign in to comment.