Skip to content

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

fix(backend:auth): exclude link users from normal auth lookups

johaven8c74d304e46a
diff --git a/backend/src/applications/users/services/users-queries.service.ts b/backend/src/applications/users/services/users-queries.service.ts
index d0e4b786..72db605c 100644
--- a/backend/src/applications/users/services/users-queries.service.ts
+++ b/backend/src/applications/users/services/users-queries.service.ts
@@ -102,7 +102,10 @@ export class UsersQueries {
if (!pQuery) {
const where = userId
? eq(users.id, sql.placeholder('userId'))
- : or(eq(users.login, sql.placeholder('loginOrEmail')), eq(users.email, sql.placeholder('loginOrEmail')))
+ : and(
+ lte(users.role, USER_ROLE.GUEST),
+ or(eq(users.login, sql.placeholder('loginOrEmail')), eq(users.email, sql.placeholder('loginOrEmail')))
+ )
pQuery = this.db
.select({
user: users,
@@ -141,7 +144,7 @@ export class UsersQueries {
.from(users)
.leftJoin(usersGroups, eq(usersGroups.userId, users.id))
.leftJoin(groups, and(eq(groups.id, usersGroups.groupId), ne(groups.permissions, '')))
- .where(or(eq(users.externalId, externalIdPlaceholder), eq(users.email, emailPlaceholder)))
+ .where(and(lte(users.role, USER_ROLE.GUEST), or(eq(users.externalId, externalIdPlaceholder), eq(users.email, emailPlaceholder))))
.groupBy(users.id)
.orderBy(desc(eq(users.externalId, externalIdPlaceholder)))
.limit(1)
diff --git a/backend/src/authentication/auth.md b/backend/src/authentication/auth.md
index de5a3044..d0c9fb99 100644
--- a/backend/src/authentication/auth.md
+++ b/backend/src/authentication/auth.md
@@ -14,6 +14,9 @@ Sync-in supports three authentication providers:
Regardless of provider, Sync-in authorizes requests with local user records, roles, permissions, and locally issued tokens after authentication
succeeds.
+Link pseudo-users are excluded from normal authentication lookups. They can only authenticate through the public link flow, using the link UUID and
+optional link password.
+
## Browser session flow
The browser login endpoint is: