Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
componentDidMount() {
const { dispatch, location } = this.props;
if (location.pathname === "/") {
// auto redirect applications
dispatch(replace("/applications"));
} else {
dispatch(replace("/404"));
}
}
// a form with branding
let { uri } = yield call(apiStartSession, processInstanceId, formName);
// we can't proxy html resources using create-react-app
// so we have to use another server to serve our custom forms
// this is only for the development
uri = updateForDev(uri);
window.location.replace(uri);
} else {
// regular form
const path = {
pathname: `/process/${processInstanceId}/form/${formName}/wizard`,
search: `fullScreen=true&yieldFlow=${yieldFlow}`
};
yield put(replaceHistory(path));
}
}
const { activeNamespaceName } = this.props;
if (!window.location.search) {
this.props.dispatch(push(`/applications/${activeNamespaceName}/components`));
}
if (prevState.subscribedPods.length !== this.state.subscribedPods.length || this.state.value !== prevState.value) {
// save selected pods in query
const search = {
...queryString.parse(window.location.search.replace("?", "")),
pods: this.state.subscribedPods.length > 0 ? this.state.subscribedPods : undefined,
active: !!this.state.value[0] ? this.state.value : undefined,
};
this.props.dispatch(
replace({
search: queryString.stringify(search),
}),
);
}
this.initFromQuery();
}
): SagaGen {
const { name, params } = action;
const next = url(name, params);
const {
router: {
location: { pathname: current },
},
} = getState();
if (next == current) {
// In several places in the code base, we use redirectTo() with the current path
// to refresh the state of the page (eg. refresh list after record deletion from the list).
// In latest versions of react-router, redirecting to the same URL does not reload the page.
// Tackling the issue at its core will happen in Kinto/kinto-admin#272
// In the mean time, let's trick the router by going to a fake URL and replacing it immediately.
yield put(updatePath("/--fake--"));
yield put(replacePath(next));
} else {
yield put(updatePath(next));
}
}
.then((response) => {
const { data } = response
const {
project_id: projectId,
path
} = data
dispatch(updateSavedProject({
name,
path,
projectId
}))
// If the URL didn't contain a projectId before, change the URL to a project URL
if (search.indexOf('?projectId=') === -1) dispatch(replace(`${pathname}?projectId=${projectId}`))
})
.catch((error) => {
.then((response) => {
const { data } = response
const {
project_id: newProjectId,
path: projectPath
} = data
newOptions = `${projectPath.split('?')[0]}?projectId=${newProjectId}`
if (projectId !== newProjectId) {
dispatch(replace(newOptions))
}
dispatch(actions.updateSavedProject({
path: projectPath,
name,
projectId: newProjectId
}))
})
.catch((error) => {
it('should logout, redirect to login and show a notification after a tick if the auth fails', async () => {
const authProvider = jest.fn(type =>
type === 'AUTH_CHECK' ? Promise.reject() : Promise.resolve()
);
const { dispatch } = renderWithRedux(
{stateInpector}
);
await wait();
expect(authProvider.mock.calls[0][0]).toBe('AUTH_CHECK');
expect(authProvider.mock.calls[1][0]).toBe('AUTH_LOGOUT');
expect(dispatch).toHaveBeenCalledTimes(2);
expect(dispatch.mock.calls[0][0]).toEqual(
replace({ pathname: '/login', state: { nextPathname: '/' } })
);
expect(dispatch.mock.calls[1][0]).toEqual(
showNotification('ra.auth.auth_check_error', 'warning')
);
});
navigateToList: appId => dispatch(replace(`/applications/${appId}/api-keys`)),
}),
ipcRenderer.once('login-success', () => {
const { config: { lastLogin } } = getState();
if (lastLogin) {
dispatch(replace('/'));
}
dispatch(setConfigKey('lastLogin', Date.now()));
});
};
function* handleAuthSuccess(action: AuthSuccessAction) {
const { options } = action.payload
if (options.returnUrl) {
yield put(replace(options.returnUrl))
} else {
const location: ReturnType = yield select(getLocation)
if (location.pathname === locations.callback()) {
yield put(replace(locations.root()))
}
}
if (options.openModal) {
yield put(openModal(options.openModal.name as any, options.openModal.metadata))
}
}