mirror of
https://github.com/WonderAliceUwU/OmniArr.git
synced 2026-11-19 19:35:56 +00:00
♻️ refactor: take the jellyfin user from the signed-in profile
Remove the Load users button and user selector from Settings, which only set the user an admin session browsed as. The Jellyfin user now always comes from the profile the session signed in with, and a value saved by older versions is ignored.
This commit is contained in:
1 parent
50bdbce1bd
commit
0e44cfb63f
2 files changed
+5
-24
No files matched your search
+5
-2
@@ -256,7 +256,8 @@ async function routeRequest(request: IncomingMessage, response: ServerResponse):
|
||||
|
||||
if (url.pathname === '/api/settings' && method === 'PUT') {
|
||||
const body = await readJson<AppConfig>(request);
|
||||
const config = sanitizeConfig(body);
|
||||
const sanitized = sanitizeConfig(body);
|
||||
const config = { ...sanitized, jellyfin: { ...sanitized.jellyfin, userId: '' } };
|
||||
await updateEncryptedConfig(encryptJson(config, await getConfigEncryptionKey()));
|
||||
const connections = await getConnectionStatuses(config);
|
||||
sendJson(response, 200, {
|
||||
@@ -603,8 +604,10 @@ async function readConfig(legacyEncryptionKey?: Buffer): Promise<AppConfig> {
|
||||
...(stored.tvdb || {})
|
||||
}
|
||||
});
|
||||
// The Jellyfin user always comes from the profile the session signed in
|
||||
// with; admin sessions have none, so a userId saved by older versions is ignored.
|
||||
const userId = legacyEncryptionKey ? sessionUsers.get(legacyEncryptionKey) : undefined;
|
||||
return userId ? { ...config, jellyfin: { ...config.jellyfin, userId } } : config;
|
||||
return { ...config, jellyfin: { ...config.jellyfin, userId: userId || '' } };
|
||||
}
|
||||
|
||||
async function getConfigEncryptionKey(): Promise<Buffer> {
|
||||
|
||||
-22
@@ -475,9 +475,7 @@ function App() {
|
||||
busy={busy}
|
||||
config={config}
|
||||
connections={connections}
|
||||
jellyfinUsersBusy={jellyfinUsersBusy}
|
||||
onExit={() => setAuthState('profiles')}
|
||||
onLoadJellyfinUsers={handleLoadJellyfinUsers}
|
||||
onSave={handleSaveSettings}
|
||||
options={options}
|
||||
updateConfig={updateConfig}
|
||||
@@ -567,8 +565,6 @@ function App() {
|
||||
busy={busy}
|
||||
config={config}
|
||||
connections={connections}
|
||||
jellyfinUsersBusy={jellyfinUsersBusy}
|
||||
onLoadJellyfinUsers={handleLoadJellyfinUsers}
|
||||
onSave={handleSaveSettings}
|
||||
options={options}
|
||||
updateConfig={updateConfig}
|
||||
@@ -3789,9 +3785,7 @@ function GlobeGlyph() {
|
||||
function AdministrationScreen(props: {
|
||||
config: AppConfig
|
||||
connections: ConnectionStatus[]
|
||||
jellyfinUsersBusy: boolean
|
||||
onExit: () => void
|
||||
onLoadJellyfinUsers: () => Promise<void>
|
||||
updateConfig: <K extends keyof AppConfig>(key: K, value: AppConfig[K]) => void
|
||||
options: ServiceOptionsResponse
|
||||
onSave: (event: FormEvent<HTMLFormElement>) => Promise<void>
|
||||
@@ -3815,8 +3809,6 @@ function AdministrationScreen(props: {
|
||||
busy={props.busy}
|
||||
config={props.config}
|
||||
connections={props.connections}
|
||||
jellyfinUsersBusy={props.jellyfinUsersBusy}
|
||||
onLoadJellyfinUsers={props.onLoadJellyfinUsers}
|
||||
onSave={props.onSave}
|
||||
options={props.options}
|
||||
formId="administration-settings"
|
||||
@@ -3830,8 +3822,6 @@ function AdministrationScreen(props: {
|
||||
function SettingsView(props: {
|
||||
config: AppConfig
|
||||
connections: ConnectionStatus[]
|
||||
jellyfinUsersBusy: boolean
|
||||
onLoadJellyfinUsers: () => Promise<void>
|
||||
updateConfig: <K extends keyof AppConfig>(key: K, value: AppConfig[K]) => void
|
||||
options: ServiceOptionsResponse
|
||||
onSave: (event: FormEvent<HTMLFormElement>) => Promise<void>
|
||||
@@ -3873,18 +3863,6 @@ function SettingsView(props: {
|
||||
onApiKeyChange={(apiKey) => props.updateConfig('jellyfin', { ...props.config.jellyfin, apiKey })}
|
||||
onBaseUrlChange={(baseUrl) => props.updateConfig('jellyfin', { ...props.config.jellyfin, baseUrl })}
|
||||
/>
|
||||
<div className="inline-actions">
|
||||
<button className="secondary-button" disabled={props.jellyfinUsersBusy || !props.config.jellyfin.baseUrl.trim() || !props.config.jellyfin.apiKey.trim()} onClick={() => void props.onLoadJellyfinUsers()} type="button">
|
||||
{props.jellyfinUsersBusy ? 'Loading users…' : 'Load users'}
|
||||
</button>
|
||||
</div>
|
||||
<label>
|
||||
User
|
||||
<select className="input" onChange={(event) => props.updateConfig('jellyfin', { ...props.config.jellyfin, userId: event.target.value })} value={props.config.jellyfin.userId}>
|
||||
<option value="">Select user</option>
|
||||
{props.options.jellyfinUsers.map((option) => <option key={option.id} value={option.id}>{option.label}</option>)}
|
||||
</select>
|
||||
</label>
|
||||
</SettingsCard>
|
||||
|
||||
<SettingsCard title="Sonarr">
|
||||
|
||||
Reference in new issue
Block a user