Files
immich/server/src/queries/session.repository.sql
Jorge Montejo 382481735a feat: logout sessions on password change (#23188)
* log out ohter sessions on password change

* translations

* update and add tests

* rename event to UserLogoutOtherSessions

* fix typo

* requested changes

* fix tests

* fix medium:test

* use ValidateBoolean

* fix format

* dont delete current session id

* Update server/src/dtos/auth.dto.ts

Co-authored-by: Daniel Dietzler <36593685+danieldietzler@users.noreply.github.com>

* rename event and invalidateOtherSessions

* chore: cleanup

---------

Co-authored-by: Daniel Dietzler <36593685+danieldietzler@users.noreply.github.com>
Co-authored-by: Jason Rasmussen <jason@rasm.me>
2025-10-27 13:16:10 +00:00

101 lines
1.7 KiB
SQL

-- NOTE: This file is auto generated by ./sql-generator
-- SessionRepository.get
select
"id",
"expiresAt",
"pinExpiresAt"
from
"session"
where
"id" = $1
-- SessionRepository.isPendingSyncReset
select
"isPendingSyncReset"
from
"session"
where
"id" = $1
-- SessionRepository.getByToken
select
"session"."id",
"session"."updatedAt",
"session"."pinExpiresAt",
"session"."appVersion",
(
select
to_json(obj)
from
(
select
"user"."id",
"user"."name",
"user"."email",
"user"."isAdmin",
"user"."quotaUsageInBytes",
"user"."quotaSizeInBytes"
from
"user"
where
"user"."id" = "session"."userId"
and "user"."deletedAt" is null
) as obj
) as "user"
from
"session"
where
"session"."token" = $1
and (
"session"."expiresAt" is null
or "session"."expiresAt" > $2
)
-- SessionRepository.getByUserId
select
"session".*
from
"session"
inner join "user" on "user"."id" = "session"."userId"
and "user"."deletedAt" is null
where
"session"."userId" = $1
and (
"session"."expiresAt" is null
or "session"."expiresAt" > $2
)
order by
"session"."updatedAt" desc,
"session"."createdAt" desc
-- SessionRepository.delete
delete from "session"
where
"id" = $1::uuid
-- SessionRepository.invalidate
delete from "session"
where
"userId" = $1
and "id" != $2
-- SessionRepository.lockAll
update "session"
set
"pinExpiresAt" = $1
where
"userId" = $2
-- SessionRepository.resetSyncProgress
begin
update "session"
set
"isPendingSyncReset" = $1
where
"id" = $2
delete from "session_sync_checkpoint"
where
"sessionId" = $1
commit