Skip to content

Commit

Permalink
Alert fix
Browse files Browse the repository at this point in the history
  • Loading branch information
RaymondLuong3 committed Jan 8, 2025
1 parent 6d7d9a2 commit 519eb72
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,40 @@ describe('AuthService', () => {
}
}));

it('should login with branding', fakeAsync(() => {
const env = new TestEnvironment();
when(mockedLocationService.origin).thenReturn('https://scriptureforge.org');

env.service.logIn({ returnUrl: 'test-returnUrl' });

verify(mockedWebAuth.loginWithRedirect(anything())).once();
const authOptions: RedirectLoginOptions | undefined = capture<RedirectLoginOptions | undefined>(
mockedWebAuth.loginWithRedirect
).last()[0];
expect(authOptions).toBeDefined();
if (authOptions != null) {
expect(authOptions.authorizationParams!.useBranding).toEqual(true);
expect(authOptions.authorizationParams!.logo).toBeDefined();
}
}));

it('should login with branding', fakeAsync(() => {
const env = new TestEnvironment();
when(mockedLocationService.origin).thenReturn('https://alternatename.org');

env.service.logIn({ returnUrl: 'test-returnUrl' });

verify(mockedWebAuth.loginWithRedirect(anything())).once();
const authOptions: RedirectLoginOptions | undefined = capture<RedirectLoginOptions | undefined>(
mockedWebAuth.loginWithRedirect
).last()[0];
expect(authOptions).toBeDefined();
if (authOptions != null) {
expect(authOptions.authorizationParams!.useBranding).toEqual(false);
expect(authOptions.authorizationParams!.logo).toBeDefined();
}
}));

it('should link with Paratext', fakeAsync(() => {
const env = new TestEnvironment({ isOnline: true, isLoggedIn: true });
const returnUrl = 'test-returnUrl';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,9 @@ export class AuthService {
const state: AuthState = { returnUrl };
const language: string = getAspCultureCookieLanguage(this.cookieService.get(ASP_CULTURE_COOKIE_NAME));
const ui_locales: string = language;
const useBranding: boolean =
this.locationService.origin.includes('scriptureforge') || this.locationService.origin.includes('localhost');
const allowedHosts = ['scriptureforge.org', 'qa.scriptureforge.org', 'localhost:5000'];
const url = new URL(this.locationService.origin);
const useBranding: boolean = allowedHosts.includes(url.host);
const auth0Parameters: xForgeAuth0Parameters = {
ui_locales: language,
enablePasswordless: true,
Expand Down

0 comments on commit 519eb72

Please sign in to comment.