mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
refactor(server): narrow auth types (#16066)
This commit is contained in:
parent
7c821dd205
commit
2d7c333c8c
25 changed files with 265 additions and 239 deletions
|
|
@ -3,29 +3,28 @@
|
|||
-- ApiKeyRepository.getKey
|
||||
select
|
||||
"api_keys"."id",
|
||||
"api_keys"."key",
|
||||
"api_keys"."userId",
|
||||
"api_keys"."permissions",
|
||||
to_json("user") as "user"
|
||||
from
|
||||
"api_keys"
|
||||
inner join lateral (
|
||||
(
|
||||
select
|
||||
"users".*,
|
||||
to_json(obj)
|
||||
from
|
||||
(
|
||||
select
|
||||
array_agg("user_metadata") as "metadata"
|
||||
"users"."id",
|
||||
"users"."name",
|
||||
"users"."email",
|
||||
"users"."isAdmin",
|
||||
"users"."quotaUsageInBytes",
|
||||
"users"."quotaSizeInBytes"
|
||||
from
|
||||
"user_metadata"
|
||||
"users"
|
||||
where
|
||||
"users"."id" = "user_metadata"."userId"
|
||||
) as "metadata"
|
||||
from
|
||||
"users"
|
||||
where
|
||||
"users"."id" = "api_keys"."userId"
|
||||
and "users"."deletedAt" is null
|
||||
) as "user" on true
|
||||
"users"."id" = "api_keys"."userId"
|
||||
and "users"."deletedAt" is null
|
||||
) as obj
|
||||
) as "user"
|
||||
from
|
||||
"api_keys"
|
||||
where
|
||||
"api_keys"."key" = $1
|
||||
|
||||
|
|
|
|||
|
|
@ -10,41 +10,29 @@ where
|
|||
|
||||
-- SessionRepository.getByToken
|
||||
select
|
||||
"sessions".*,
|
||||
to_json("user") as "user"
|
||||
from
|
||||
"sessions"
|
||||
inner join lateral (
|
||||
"sessions"."id",
|
||||
"sessions"."updatedAt",
|
||||
(
|
||||
select
|
||||
"id",
|
||||
"email",
|
||||
"createdAt",
|
||||
"profileImagePath",
|
||||
"isAdmin",
|
||||
"shouldChangePassword",
|
||||
"deletedAt",
|
||||
"oauthId",
|
||||
"updatedAt",
|
||||
"storageLabel",
|
||||
"name",
|
||||
"quotaSizeInBytes",
|
||||
"quotaUsageInBytes",
|
||||
"status",
|
||||
"profileChangedAt",
|
||||
to_json(obj)
|
||||
from
|
||||
(
|
||||
select
|
||||
array_agg("user_metadata") as "metadata"
|
||||
"users"."id",
|
||||
"users"."name",
|
||||
"users"."email",
|
||||
"users"."isAdmin",
|
||||
"users"."quotaUsageInBytes",
|
||||
"users"."quotaSizeInBytes"
|
||||
from
|
||||
"user_metadata"
|
||||
"users"
|
||||
where
|
||||
"users"."id" = "user_metadata"."userId"
|
||||
) as "metadata"
|
||||
from
|
||||
"users"
|
||||
where
|
||||
"users"."id" = "sessions"."userId"
|
||||
and "users"."deletedAt" is null
|
||||
) as "user" on true
|
||||
"users"."id" = "sessions"."userId"
|
||||
and "users"."deletedAt" is null
|
||||
) as obj
|
||||
) as "user"
|
||||
from
|
||||
"sessions"
|
||||
where
|
||||
"sessions"."token" = $1
|
||||
|
||||
|
|
|
|||
|
|
@ -153,12 +153,19 @@ where
|
|||
"shared_links"."type" = $2
|
||||
or "album"."id" is not null
|
||||
)
|
||||
and "shared_links"."albumId" = $3
|
||||
order by
|
||||
"shared_links"."createdAt" desc
|
||||
|
||||
-- SharedLinkRepository.getByKey
|
||||
select
|
||||
"shared_links".*,
|
||||
"shared_links"."id",
|
||||
"shared_links"."userId",
|
||||
"shared_links"."expiresAt",
|
||||
"shared_links"."showExif",
|
||||
"shared_links"."allowUpload",
|
||||
"shared_links"."allowDownload",
|
||||
"shared_links"."password",
|
||||
(
|
||||
select
|
||||
to_json(obj)
|
||||
|
|
@ -166,20 +173,11 @@ select
|
|||
(
|
||||
select
|
||||
"users"."id",
|
||||
"users"."email",
|
||||
"users"."createdAt",
|
||||
"users"."profileImagePath",
|
||||
"users"."isAdmin",
|
||||
"users"."shouldChangePassword",
|
||||
"users"."deletedAt",
|
||||
"users"."oauthId",
|
||||
"users"."updatedAt",
|
||||
"users"."storageLabel",
|
||||
"users"."name",
|
||||
"users"."quotaSizeInBytes",
|
||||
"users"."email",
|
||||
"users"."isAdmin",
|
||||
"users"."quotaUsageInBytes",
|
||||
"users"."status",
|
||||
"users"."profileChangedAt"
|
||||
"users"."quotaSizeInBytes"
|
||||
from
|
||||
"users"
|
||||
where
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue