From c4f5dc6d018234d026f742e3deaf6d8895941f87 Mon Sep 17 00:00:00 2001 From: Jason Rasmussen Date: Wed, 26 Apr 2023 16:39:18 -0400 Subject: [PATCH] fix(server): oauth mobile callback url (#2339) * fix(server): mobile redirect uri * chore: add test --- server/libs/domain/src/oauth/oauth.core.ts | 2 +- server/libs/domain/src/oauth/oauth.service.spec.ts | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/server/libs/domain/src/oauth/oauth.core.ts b/server/libs/domain/src/oauth/oauth.core.ts index a901d2bd68..3ebf97439d 100644 --- a/server/libs/domain/src/oauth/oauth.core.ts +++ b/server/libs/domain/src/oauth/oauth.core.ts @@ -97,7 +97,7 @@ export class OAuthCore { } private normalize(redirectUri: string) { - const isMobile = redirectUri === MOBILE_REDIRECT; + const isMobile = redirectUri.startsWith(MOBILE_REDIRECT); const { mobileRedirectUri, mobileOverrideEnabled } = this.config.oauth; if (isMobile && mobileOverrideEnabled && mobileRedirectUri) { return mobileRedirectUri; diff --git a/server/libs/domain/src/oauth/oauth.service.spec.ts b/server/libs/domain/src/oauth/oauth.service.spec.ts index 18c45416bd..c79e09e7ec 100644 --- a/server/libs/domain/src/oauth/oauth.service.spec.ts +++ b/server/libs/domain/src/oauth/oauth.service.spec.ts @@ -154,6 +154,17 @@ describe('OAuthService', () => { expect(callbackMock).toHaveBeenCalledWith('http://mobile-redirect', { state: 'state' }, { state: 'state' }); }); + + it('should use the mobile redirect override for ios urls with multiple slashes', async () => { + sut = create(systemConfigStub.override); + + userMock.getByOAuthId.mockResolvedValue(userEntityStub.user1); + userTokenMock.create.mockResolvedValue(userTokenEntityStub.userToken); + + await sut.login({ url: `app.immich:///?code=abc123` }, loginDetails); + + expect(callbackMock).toHaveBeenCalledWith('http://mobile-redirect', { state: 'state' }, { state: 'state' }); + }); }); describe('link', () => {