fix oauth providers (turn back site id)

This commit is contained in:
Pavel Mineev
2021-02-04 13:09:59 -06:00
committed by Umputun
parent 2e43f09636
commit 3628467367
3 changed files with 18 additions and 2 deletions
+16
View File
@@ -0,0 +1,16 @@
jest.mock('./settings', () => ({
siteId: 'remark',
}));
import { logIn } from './api';
describe('api', () => {
it('should open oauth endpoint with right url', () => {
window.open = jest.fn().mockImplementationOnce(jest.fn());
logIn({ name: 'google' });
expect(window.open).toHaveBeenCalledWith(
'/auth/google/login?from=http%3A%2F%2Flocalhost%2F%3FselfClose&site=remark'
);
});
});
+1 -1
View File
@@ -29,7 +29,7 @@ export const logIn = (provider: AuthProvider): Promise<User | null> => {
if (provider.name === 'email') return __loginViaEmail(provider.token);
return new Promise<User | null>((resolve, reject) => {
const queryString = new URLSearchParams({ from: FROM_URL });
const queryString = new URLSearchParams({ from: FROM_URL, site: siteId });
const newWindow = window.open(`/auth/${provider.name}/login?${queryString}`);
let secondsPass = 0;
const checkMsDelay = 300;
+1 -1
View File
@@ -32,7 +32,7 @@ function mockFetch({ headers = {}, data = {}, ...props }: FetchImplementaitonPro
describe('fetcher', () => {
const headers = { [XSRF_HEADER]: '' };
const apiUri = `/anything`;
const apiUri = '/anything';
const apiUrl = `${BASE_URL}${API_BASE}/anything?site=remark`;
describe('methods', () => {