diff --git a/backend/LexBoxApi/Controllers/UserController.cs b/backend/LexBoxApi/Controllers/UserController.cs index ac48f3f52..912ceb0d1 100644 --- a/backend/LexBoxApi/Controllers/UserController.cs +++ b/backend/LexBoxApi/Controllers/UserController.cs @@ -184,7 +184,7 @@ private User CreateUserEntity(RegisterAccountInput input, LexAuthUser? jwtUser, EmailVerified = jwtUser?.Email == input.Email, CreatedById = creatorId, Locked = false, - CanCreateProjects = false + CanCreateProjects = jwtUser?.Email == input.Email && jwtUser.CanCreateProjects == true, }; UpdateUserMemberships(jwtUser, userEntity); return userEntity; diff --git a/backend/LexBoxApi/Services/EmailService.cs b/backend/LexBoxApi/Services/EmailService.cs index 6a7215c9f..914e5f148 100644 --- a/backend/LexBoxApi/Services/EmailService.cs +++ b/backend/LexBoxApi/Services/EmailService.cs @@ -103,7 +103,7 @@ public async Task SendCreateAccountWithOrgEmail( string? language = null) { language ??= User.DefaultLocalizationCode; - var authUser = CreateUserForInvite(emailAddress, language); + var authUser = CreateUserForInvite(emailAddress, language, canCreateProjects: orgRole == OrgRole.Admin); authUser.Orgs = [new AuthUserOrg(orgRole, orgId)]; await SendInvitationEmail(authUser, emailAddress, managerName, orgName, language, isProjectInvitation: false); @@ -124,12 +124,12 @@ public async Task SendCreateAccountWithProjectEmail( string? language = null) { language ??= User.DefaultLocalizationCode; - var authUser = CreateUserForInvite(emailAddress, language); + var authUser = CreateUserForInvite(emailAddress, language, canCreateProjects: role == ProjectRole.Manager); authUser.Projects = [new AuthUserProject(role, projectId)]; await SendInvitationEmail(authUser, emailAddress, managerName, projectName, language, isProjectInvitation: true); } - private LexAuthUser CreateUserForInvite(string emailAddress, string? language) + private LexAuthUser CreateUserForInvite(string emailAddress, string? language, bool canCreateProjects = false) { language ??= User.DefaultLocalizationCode; return new LexAuthUser @@ -141,7 +141,7 @@ private LexAuthUser CreateUserForInvite(string emailAddress, string? language) EmailVerificationRequired = null, Role = UserRole.user, UpdatedDate = DateTimeOffset.Now.ToUnixTimeSeconds(), - CanCreateProjects = null, + CanCreateProjects = canCreateProjects ? true : null, Locale = language, Locked = null, Projects = [],