Skip to content

Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.

feat(backend:users): add showUngroupedUsers toggle for ungrouped account visibility

johaven2fad377cb929
diff --git a/backend/src/applications/applications.config.ts b/backend/src/applications/applications.config.ts
index 278c20de..f51d22ec 100644
--- a/backend/src/applications/applications.config.ts
+++ b/backend/src/applications/applications.config.ts
@@ -2,6 +2,7 @@ import { Type } from 'class-transformer'
import { IsDefined, IsNotEmptyObject, IsObject, ValidateNested } from 'class-validator'
import { FilesConfig } from './files/files.config'
import { AppStoreConfig } from './sync/sync.config'
+import { UsersConfig } from './users/users.config'
export class ApplicationsConfig {
@IsDefined()
@@ -11,6 +12,13 @@ export class ApplicationsConfig {
@Type(() => FilesConfig)
files: FilesConfig
+ @IsDefined()
+ @IsObject()
+ @IsNotEmptyObject()
+ @ValidateNested()
+ @Type(() => UsersConfig)
+ users: UsersConfig = new UsersConfig()
+
@IsDefined()
@IsObject()
@IsNotEmptyObject()
diff --git a/backend/src/applications/users/services/users-queries.service.ts b/backend/src/applications/users/services/users-queries.service.ts
index 0404b69d..d815d90d 100644
--- a/backend/src/applications/users/services/users-queries.service.ts
+++ b/backend/src/applications/users/services/users-queries.service.ts
@@ -5,6 +5,7 @@ import { MySql2PreparedQuery, MySqlQueryResult } from 'drizzle-orm/mysql2'
import { anonymizePassword, comparePassword, uniquePermissions } from '../../../common/functions'
import { CacheDecorator } from '../../../infrastructure/cache/cache.decorator'
import { Cache } from '../../../infrastructure/cache/services/cache.service'
+import { configuration } from '../../../configuration/config.environment'
import { DB_TOKEN_PROVIDER } from '../../../infrastructure/database/constants'
import { DBSchema } from '../../../infrastructure/database/interfaces/database.interface'
import {
@@ -484,12 +485,15 @@ export class UsersQueries {
@CacheDecorator(900)
async usersWhitelist(userId: number, lowerOrEqualUserRole: USER_ROLE = USER_ROLE.GUEST): Promise<number[]> {
/* Get the list of user ids allowed to the current user
- - all users with no groups (except users with a role higher than lowerOrEqualUserRole, and except for guest requester)
+ - users with no groups only when applications.users.showUngroupedUsers = true
+ (guest accounts are excluded from this global branch, and guest requesters never get this branch)
+ (also excludes users with a role higher than lowerOrEqualUserRole)
- all users who are members of groups visible to the current user
(VISIBLE groups for everyone, PRIVATE groups only if the current user is a member, never members of ISOLATED groups)
- all guests managed by the current user
- all managers who manage the current guest
*/
+ const showUngroupedUsers = +configuration.applications.users.showUngroupedUsers
const userIds: any = sql`
WITH visible_groups AS (
SELECT ${groups.id} AS id
@@ -524,6 +528,8 @@ export class UsersQueries {
SELECT ${users.id} AS id
FROM ${users}
WHERE
+ ${showUngroupedUsers} = 1
+ AND
${users.role} <= ${sql.raw(`${lowerOrEqualUserRole}`)}
-- Guests without (personal) groups are not globally visible.
-- They are allowed only through part 1 (shared visible group) or part 3 (manager relation).
diff --git a/backend/src/applications/users/users.config.ts b/backend/src/applications/users/users.config.ts
new file mode 100644
index 00000000..a48ca1df
--- /dev/null
+++ b/backend/src/applications/users/users.config.ts
@@ -0,0 +1,6 @@
+import { IsBoolean } from 'class-validator'
+
+export class UsersConfig {
+ @IsBoolean()
+ showUngroupedUsers = true
+}
diff --git a/environment/environment.dist.yaml b/environment/environment.dist.yaml
index 9e76cf28..de1c9eef 100755
--- a/environment/environment.dist.yaml
+++ b/environment/environment.dist.yaml
@@ -295,6 +295,11 @@ auth:
# default: false
skipSubjectCheck: false
applications:
+ users:
+ # showUngroupedUsers: make users without a group globally visible to regular users/admins.
+ # Guest accounts are excluded from this global visibility (both as listed accounts and as requesters).
+ # default: `true`
+ showUngroupedUsers: true
files:
# required
dataPath: /home/sync-in