#819 add flag on the login component

This commit is contained in:
Mario Romano
2016-09-27 00:33:15 +01:00
parent 07f6bb2552
commit 63fd6591d5
8 changed files with 119 additions and 102 deletions

View File

@@ -61,11 +61,6 @@
<input type="text" class="mdl-textfield__input" id="bpmHost" data-automation-id="bpmHost"
tabindex="1" (change)="onChangeBPMHost($event)" value="{{bpmHost}}"/>
</nav>
<span class="mdl-layout-title">CSRF Token Disabled</span>
<nav class="mdl-navigation">
<input type="text" class="mdl-textfield__input" id="csrfDisabled" data-automation-id="csrfDisabled"
tabindex="1" (change)="onChangeCsrf($event)" value="{{csrfDisabled}}"/>
</nav>
</div>
<main class="mdl-layout__content">
<div class="page-content">

View File

@@ -37,7 +37,6 @@ export class AppComponent {
ecmHost: string = 'http://' + window.location.hostname + ':8080';
bpmHost: string = 'http://' + window.location.hostname + ':9999';
csrfDisabled: boolean = false;
constructor(public auth: AlfrescoAuthenticationService,
public router: Router,
@@ -45,7 +44,6 @@ export class AppComponent {
public alfrescoSettingsService: AlfrescoSettingsService) {
this.setEcmHost();
this.setBpmHost();
this.setCsrfToken();
this.translate = translate;
this.translate.addTranslationFolder();
@@ -65,13 +63,6 @@ export class AppComponent {
localStorage.setItem(`bpmHost`, this.bpmHost);
}
public onChangeCsrf(event: KeyboardEvent): void {
console.log((<HTMLInputElement>event.target).value);
this.csrfDisabled = !!(<HTMLInputElement>event.target).value;
this.alfrescoSettingsService.csrfDisabled = this.csrfDisabled;
localStorage.setItem(`csrfDisabled`, this.csrfDisabled.toString());
}
isLoggedIn(): boolean {
return this.auth.isLoggedIn();
}
@@ -129,13 +120,4 @@ export class AppComponent {
this.alfrescoSettingsService.bpmHost = this.bpmHost;
}
}
private setCsrfToken() {
if (localStorage.getItem(`csrfDisabled`)) {
this.alfrescoSettingsService.bpmHost = localStorage.getItem(`csrfDisabled`);
this.csrfDisabled = !!localStorage.getItem(`csrfDisabled`);
} else {
this.alfrescoSettingsService.csrfDisabled = this.csrfDisabled;
}
}
}

View File

@@ -11,12 +11,18 @@
<span class="mdl-switch__label">BPM</span>
</label>
</p>
<p class="toggle">
<label for="switch3" class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
<input type="checkbox" id="switch3" class="mdl-switch__input" checked (click)="toggleCSRF()" #csrf>
<span class="mdl-switch__label">CSRF</span>
</label>
</p>
<p class="banned">
<label for="blacklistusername">Banned username</label><br>
<input id="blacklistusername" type="text" placeholder="banned username" [(ngModel)]="blackListUsername" />
</p>
</div>
<alfresco-login [providers]="providers" [fieldsValidation]="customValidation"
<alfresco-login [providers]="providers" [fieldsValidation]="customValidation" [disableCsrf]="disableCsrf"
(executeSubmit)="validateForm($event)"
(onSuccess)="onLogin($event)"
(onError)="onError($event)" #alfrescologin></alfresco-login>

View File

@@ -33,6 +33,7 @@ export class LoginDemoComponent implements OnInit {
alfrescologin: any;
providers: string = 'ECM';
disableCsrf: boolean = false;
blackListUsername: string;
customValidation: any;
@@ -82,6 +83,10 @@ export class LoginDemoComponent implements OnInit {
}
}
toggleCSRF() {
this.disableCsrf = !this.disableCsrf;
}
validateForm(event: any) {
let values = event.values;
if (values.controls['username'].value === this.blackListUsername ) {