Only the username form control should be emitted (#3333)

This commit is contained in:
Maurizio Vitale
2018-05-16 15:45:39 +01:00
committed by Eugenio Romano
parent 3f9dc53722
commit 0ebd4c62e3
2 changed files with 13 additions and 2 deletions

View File

@@ -571,4 +571,16 @@ describe('LoginComponent', () => {
loginWithCredentials('fake-username', 'fake-password', null); loginWithCredentials('fake-username', 'fake-password', null);
})); }));
it('should emit only the username and not the password as part of the executeSubmit', async(() => {
component.executeSubmit.subscribe((res) => {
fixture.detectChanges();
expect(res.values.controls.username).toBeDefined('username mandatory');
expect(res.values.controls.username.value).toEqual('fake-username');
expect(res.values.controls.password).toBeUndefined('The password not not be part of the emitted values');
});
loginWithCredentials('fake-username', 'fake-password');
}));
}); });

View File

@@ -174,8 +174,7 @@ export class LoginComponent implements OnInit {
this.settingsService.csrfDisabled = this.disableCsrf; this.settingsService.csrfDisabled = this.disableCsrf;
this.disableError(); this.disableError();
const args = new LoginSubmitEvent({controls : { username : this.form.controls.username} });
const args = new LoginSubmitEvent(this.form);
this.executeSubmit.emit(args); this.executeSubmit.emit(args);
if (args.defaultPrevented) { if (args.defaultPrevented) {