From 0ebd4c62e308daf44f8275af9fda7dd151985deb Mon Sep 17 00:00:00 2001 From: Maurizio Vitale Date: Wed, 16 May 2018 15:45:39 +0100 Subject: [PATCH] Only the username form control should be emitted (#3333) --- lib/core/login/components/login.component.spec.ts | 12 ++++++++++++ lib/core/login/components/login.component.ts | 3 +-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/core/login/components/login.component.spec.ts b/lib/core/login/components/login.component.spec.ts index a614666b28..291b54fb7f 100644 --- a/lib/core/login/components/login.component.spec.ts +++ b/lib/core/login/components/login.component.spec.ts @@ -571,4 +571,16 @@ describe('LoginComponent', () => { 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'); + })); }); diff --git a/lib/core/login/components/login.component.ts b/lib/core/login/components/login.component.ts index 57f47e03ac..f5f3a41d70 100644 --- a/lib/core/login/components/login.component.ts +++ b/lib/core/login/components/login.component.ts @@ -174,8 +174,7 @@ export class LoginComponent implements OnInit { this.settingsService.csrfDisabled = this.disableCsrf; this.disableError(); - - const args = new LoginSubmitEvent(this.form); + const args = new LoginSubmitEvent({controls : { username : this.form.controls.username} }); this.executeSubmit.emit(args); if (args.defaultPrevented) {