diff --git a/front/lib/auth.ts b/front/lib/auth.ts index 943bacf136b0..5f41b797ea39 100644 --- a/front/lib/auth.ts +++ b/front/lib/auth.ts @@ -129,28 +129,16 @@ export class Authenticator { if (user && workspace) { [role, subscription, flags] = await Promise.all([ - (async (): Promise => { - const membership = - await MembershipResource.getActiveMembershipOfUserInWorkspace({ - user: renderUserType(user), - workspace: renderLightWorkspaceType({ workspace }), - }); - return membership && - // TODO(@fontanierh): get rid of the check ? - ["admin", "builder", "user"].includes(membership.role) - ? (membership.role as RoleType) - : "none"; - })(), + MembershipResource.getActiveMembershipOfUserInWorkspace({ + user: renderUserType(user), + workspace: renderLightWorkspaceType({ workspace }), + }).then((m) => m?.role ?? "none"), subscriptionForWorkspace(workspace.sId), - (async () => { - return ( - await FeatureFlag.findAll({ - where: { - workspaceId: workspace.id, - }, - }) - ).map((flag) => flag.name); - })(), + FeatureFlag.findAll({ + where: { + workspaceId: workspace.id, + }, + }).then((flags) => flags.map((flag) => flag.name)), ]); } diff --git a/front/lib/resources/membership_resource.ts b/front/lib/resources/membership_resource.ts index cdbfc604fd84..fd1453ac62db 100644 --- a/front/lib/resources/membership_resource.ts +++ b/front/lib/resources/membership_resource.ts @@ -352,7 +352,7 @@ export class MembershipResource extends BaseResource { } // If the membership is not terminated, we update the role in place. - // TODO(@fontanierh): check if we want to terminate + create a new membership with new role instead ? + // We do not historicize the roles. if (!membership.endAt) { if (membership.role === newRole) { return new Err({ type: "already_on_role" });