diff --git a/docs/docs/administration/oauth.md b/docs/docs/administration/oauth.md index 2dc69909446..b60b5dbb8bf 100644 --- a/docs/docs/administration/oauth.md +++ b/docs/docs/administration/oauth.md @@ -93,6 +93,7 @@ The `.well-known/openid-configuration` part of the url is optional and will be a ## Auto Launch When Auto Launch is enabled, the login page will automatically redirect the user to the OAuth authorization url, to login with OAuth. To access the login screen again, use the browser's back button, or navigate directly to `/auth/login?autoLaunch=0`. +Auto Launch can also be enabled on a per-request basis by navigating to `/auth/login?authLaunch=1`, this can be useful in situations where Immich is called from e.g. Nextcloud using the _External sites_ app and the _oidc_ app so as to enable users to directly interact with a logged-in instance of Immich. ## Mobile Redirect URI diff --git a/web/src/lib/utils.ts b/web/src/lib/utils.ts index 645c485cc5a..bfb8998781a 100644 --- a/web/src/lib/utils.ts +++ b/web/src/lib/utils.ts @@ -275,6 +275,10 @@ export const oauth = { } return false; }, + isAutoLaunchEnabled: (location: Location) => { + const value = 'autoLaunch=1'; + return location.search.includes(value); + }, authorize: async (location: Location) => { const $t = get(t); try { diff --git a/web/src/routes/auth/login/+page.svelte b/web/src/routes/auth/login/+page.svelte index 5cce88ae2cd..7937a55f80c 100644 --- a/web/src/routes/auth/login/+page.svelte +++ b/web/src/routes/auth/login/+page.svelte @@ -53,7 +53,10 @@ } try { - if ($featureFlags.oauthAutoLaunch && !oauth.isAutoLaunchDisabled(globalThis.location)) { + if ( + ($featureFlags.oauthAutoLaunch && !oauth.isAutoLaunchDisabled(globalThis.location)) || + oauth.isAutoLaunchEnabled(globalThis.location) + ) { await goto(`${AppRoute.AUTH_LOGIN}?autoLaunch=0`, { replaceState: true }); await oauth.authorize(globalThis.location); return;