fix oauth providers (turn back site id)
This commit is contained in:
@@ -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'
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -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;
|
||||
|
||||
@@ -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', () => {
|
||||
|
||||
Reference in New Issue
Block a user