mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-12-27 01:11:13 -06:00
SDA-3592 Prevent redirection on form submission (#1365)
This commit is contained in:
parent
43df94f828
commit
5ce8544273
@ -33,12 +33,13 @@ describe('basic auth', () => {
|
||||
});
|
||||
|
||||
it('should call submit login', () => {
|
||||
const fakeEvent = { preventDefault: () => {} };
|
||||
const { ipcRenderer } = require('./__mocks__/electron');
|
||||
const spy: jest.SpyInstance = jest.spyOn(ipcRenderer, 'send');
|
||||
const wrapper: ShallowWrapper = shallow(React.createElement(BasicAuth));
|
||||
wrapper.find('#username').simulate('change', usernameTargetMock);
|
||||
wrapper.find('#password').simulate('change', passwordTargetMock);
|
||||
wrapper.find('#basicAuth').simulate('submit');
|
||||
wrapper.find('#basicAuth').simulate('submit', fakeEvent);
|
||||
expect(spy).lastCalledWith('basic-auth-login', {
|
||||
...usernameMock,
|
||||
...passwordMock,
|
||||
|
@ -1493,13 +1493,20 @@ export class WindowHandler {
|
||||
{
|
||||
width: 360,
|
||||
height: isMac ? 270 : 295,
|
||||
alwaysOnTop: true,
|
||||
skipTaskbar: true,
|
||||
resizable: false,
|
||||
show: false,
|
||||
modal: true,
|
||||
autoHideMenuBar: true,
|
||||
resizable: false,
|
||||
frame: false,
|
||||
transparent: true,
|
||||
fullscreenable: false,
|
||||
acceptFirstMouse: true,
|
||||
},
|
||||
{
|
||||
devTools: isDevEnv,
|
||||
sandbox: IS_SAND_BOXED,
|
||||
nodeIntegration: IS_NODE_INTEGRATION_ENABLED,
|
||||
devTools: true,
|
||||
},
|
||||
);
|
||||
opts.parent = window;
|
||||
|
@ -19,7 +19,7 @@ const BASIC_AUTH_NAMESPACE = 'BasicAuth';
|
||||
export default class BasicAuth extends React.Component<{}, IState> {
|
||||
private readonly eventHandlers = {
|
||||
onChange: (event) => this.change(event),
|
||||
onSubmit: () => this.submit(),
|
||||
onSubmit: (event) => this.submit(event),
|
||||
onClose: () => this.close(),
|
||||
};
|
||||
|
||||
@ -140,7 +140,8 @@ export default class BasicAuth extends React.Component<{}, IState> {
|
||||
/**
|
||||
* Submits the form with provided username and password info
|
||||
*/
|
||||
private submit(): void {
|
||||
private submit(event): void {
|
||||
event.preventDefault();
|
||||
const { username, password } = this.state;
|
||||
if (username && password) {
|
||||
ipcRenderer.send('basic-auth-login', { username, password });
|
||||
|
Loading…
Reference in New Issue
Block a user