refactor: lock session (#25366)

refafctor: lock session
This commit is contained in:
Jason Rasmussen
2026-01-19 11:47:58 -05:00
committed by GitHub
parent b123beae38
commit a8198f9934
3 changed files with 48 additions and 13 deletions
@@ -65,6 +65,8 @@ export type Events = {
// confirmed permanently deleted from server
UserAdminDeleted: [{ id: string }];
SessionLocked: [];
SystemConfigUpdate: [SystemConfigDto];
LibraryCreate: [LibraryResponseDto];
+32 -2
View File
@@ -1,8 +1,38 @@
import { eventManager } from '$lib/managers/event-manager.svelte';
import { handleError } from '$lib/utils/handle-error';
import { getFormatter } from '$lib/utils/i18n';
import { changePassword, resetPinCode, type ChangePasswordDto, type PinCodeResetDto } from '@immich/sdk';
import { toastManager } from '@immich/ui';
import {
changePassword,
lockAuthSession,
resetPinCode,
type ChangePasswordDto,
type PinCodeResetDto,
} from '@immich/sdk';
import { toastManager, type ActionItem } from '@immich/ui';
import { mdiLockOutline } from '@mdi/js';
import type { MessageFormatter } from 'svelte-i18n';
export const getUserActions = ($t: MessageFormatter) => {
const LockSession: ActionItem = {
title: $t('lock'),
color: 'primary',
icon: mdiLockOutline,
onAction: () => handleLockSession(),
};
return { LockSession };
};
const handleLockSession = async () => {
const $t = await getFormatter();
try {
await lockAuthSession();
eventManager.emit('SessionLocked');
} catch (error) {
handleError(error, $t('errors.something_went_wrong'));
}
};
export const handleResetPinCode = async (dto: PinCodeResetDto) => {
const $t = await getFormatter();