Standardize query auth check
This commit is contained in:
parent
ee95719f8c
commit
e16dbb80a4
@ -9,7 +9,7 @@ import {
|
||||
getPhoto,
|
||||
getPhotos,
|
||||
} from '@/photo/db/query';
|
||||
import { GetPhotosOptions } from './db';
|
||||
import { GetPhotosOptions, areOptionsSensitive } from './db';
|
||||
import {
|
||||
PhotoFormData,
|
||||
convertFormDataToPhotoDbInsert,
|
||||
@ -392,13 +392,13 @@ export const getPhotosHiddenMetaCachedAction = async () =>
|
||||
// Public/Private actions
|
||||
|
||||
export const getPhotosAction = async (options: GetPhotosOptions) =>
|
||||
(options.hidden === 'include' || options.hidden === 'only')
|
||||
areOptionsSensitive(options)
|
||||
? runAuthenticatedAdminServerAction(() => getPhotos(options))
|
||||
: getPhotos(options);
|
||||
|
||||
export const getPhotosCachedAction = async (options: GetPhotosOptions) =>
|
||||
(options.hidden === 'include' || options.hidden === 'only')
|
||||
? runAuthenticatedAdminServerAction(() => getPhotosCached (options))
|
||||
areOptionsSensitive(options)
|
||||
? runAuthenticatedAdminServerAction(() => getPhotosCached(options))
|
||||
: getPhotosCached(options);
|
||||
|
||||
// Public actions
|
||||
|
||||
@ -23,6 +23,9 @@ export type GetPhotosOptions = {
|
||||
hidden?: 'exclude' | 'include' | 'only'
|
||||
};
|
||||
|
||||
export const areOptionsSensitive = (options: GetPhotosOptions) =>
|
||||
options.hidden === 'include' || options.hidden === 'only';
|
||||
|
||||
export const getWheresFromOptions = (
|
||||
options: GetPhotosOptions,
|
||||
initialValuesIndex = 1
|
||||
|
||||
Loading…
Reference in New Issue
Block a user