mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
refactor(server): sessions (#8915)
* refactor: auth device => sessions * chore: open api
This commit is contained in:
parent
e72e41a7aa
commit
4478e524f8
48 changed files with 967 additions and 825 deletions
|
|
@ -1,7 +1,7 @@
|
|||
<script lang="ts">
|
||||
import Icon from '$lib/components/elements/icon.svelte';
|
||||
import { locale } from '$lib/stores/preferences.store';
|
||||
import type { AuthDeviceResponseDto } from '@immich/sdk';
|
||||
import type { SessionResponseDto } from '@immich/sdk';
|
||||
import {
|
||||
mdiAndroid,
|
||||
mdiApple,
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
import { DateTime, type ToRelativeCalendarOptions } from 'luxon';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
|
||||
export let device: AuthDeviceResponseDto;
|
||||
export let device: SessionResponseDto;
|
||||
|
||||
const dispatcher = createEventDispatcher<{
|
||||
delete: void;
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
<script lang="ts">
|
||||
import { getAuthDevices, logoutAuthDevice, logoutAuthDevices, type AuthDeviceResponseDto } from '@immich/sdk';
|
||||
import { deleteAllSessions, deleteSession, getSessions, type SessionResponseDto } from '@immich/sdk';
|
||||
import { handleError } from '../../utils/handle-error';
|
||||
import Button from '../elements/buttons/button.svelte';
|
||||
import ConfirmDialogue from '../shared-components/confirm-dialogue.svelte';
|
||||
import { NotificationType, notificationController } from '../shared-components/notification/notification';
|
||||
import { notificationController, NotificationType } from '../shared-components/notification/notification';
|
||||
import DeviceCard from './device-card.svelte';
|
||||
|
||||
export let devices: AuthDeviceResponseDto[];
|
||||
let deleteDevice: AuthDeviceResponseDto | null = null;
|
||||
export let devices: SessionResponseDto[];
|
||||
let deleteDevice: SessionResponseDto | null = null;
|
||||
let deleteAll = false;
|
||||
|
||||
const refresh = () => getAuthDevices().then((_devices) => (devices = _devices));
|
||||
const refresh = () => getSessions().then((_devices) => (devices = _devices));
|
||||
|
||||
$: currentDevice = devices.find((device) => device.current);
|
||||
$: otherDevices = devices.filter((device) => !device.current);
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
}
|
||||
|
||||
try {
|
||||
await logoutAuthDevice({ id: deleteDevice.id });
|
||||
await deleteSession({ id: deleteDevice.id });
|
||||
notificationController.show({ message: `Logged out device`, type: NotificationType.Info });
|
||||
} catch (error) {
|
||||
handleError(error, 'Unable to log out device');
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
const handleDeleteAll = async () => {
|
||||
try {
|
||||
await logoutAuthDevices();
|
||||
await deleteAllSessions();
|
||||
notificationController.show({
|
||||
message: `Logged out all devices`,
|
||||
type: NotificationType.Info,
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@
|
|||
import { featureFlags } from '$lib/stores/server-config.store';
|
||||
import { user } from '$lib/stores/user.store';
|
||||
import { oauth } from '$lib/utils';
|
||||
import { type ApiKeyResponseDto, type AuthDeviceResponseDto } from '@immich/sdk';
|
||||
import { type ApiKeyResponseDto, type SessionResponseDto } from '@immich/sdk';
|
||||
import SettingAccordionState from '../shared-components/settings/setting-accordion-state.svelte';
|
||||
import SettingAccordion from '../shared-components/settings/setting-accordion.svelte';
|
||||
import AppSettings from './app-settings.svelte';
|
||||
import ChangePasswordSettings from './change-password-settings.svelte';
|
||||
|
|
@ -14,10 +15,9 @@
|
|||
import PartnerSettings from './partner-settings.svelte';
|
||||
import UserAPIKeyList from './user-api-key-list.svelte';
|
||||
import UserProfileSettings from './user-profile-settings.svelte';
|
||||
import SettingAccordionState from '../shared-components/settings/setting-accordion-state.svelte';
|
||||
|
||||
export let keys: ApiKeyResponseDto[] = [];
|
||||
export let devices: AuthDeviceResponseDto[] = [];
|
||||
export let sessions: SessionResponseDto[] = [];
|
||||
|
||||
let oauthOpen =
|
||||
oauth.isCallback(window.location) ||
|
||||
|
|
@ -38,7 +38,7 @@
|
|||
</SettingAccordion>
|
||||
|
||||
<SettingAccordion key="authorized-devices" title="Authorized Devices" subtitle="Manage your logged-in devices">
|
||||
<DeviceList bind:devices />
|
||||
<DeviceList bind:devices={sessions} />
|
||||
</SettingAccordion>
|
||||
|
||||
<SettingAccordion key="memories" title="Memories" subtitle="Manage what you see in your memories">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue