mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
Use the custom validation
This commit is contained in:
@@ -12,4 +12,6 @@
|
|||||||
</label>
|
</label>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<alfresco-login [providers]="providers" (onSuccess)="onLogin($event)" (onError)="onError($event)"></alfresco-login>
|
<alfresco-login (executeOutcome)="validateForm($event)" [providers]="providers"
|
||||||
|
(onSuccess)="onLogin($event)"
|
||||||
|
(onError)="onError($event)" #alfrescologin></alfresco-login>
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {Component} from '@angular/core';
|
import {Component, ViewChild} from '@angular/core';
|
||||||
import {AlfrescoLoginComponent} from 'ng2-alfresco-login';
|
import {AlfrescoLoginComponent} from 'ng2-alfresco-login';
|
||||||
import {ROUTER_DIRECTIVES, Router} from '@angular/router';
|
import {ROUTER_DIRECTIVES, Router} from '@angular/router';
|
||||||
|
|
||||||
@@ -30,6 +30,9 @@ declare let __moduleName: string;
|
|||||||
})
|
})
|
||||||
export class LoginDemoComponent {
|
export class LoginDemoComponent {
|
||||||
|
|
||||||
|
@ViewChild('alfrescologin')
|
||||||
|
alfrescologin: any;
|
||||||
|
|
||||||
providers: string = 'ECM';
|
providers: string = 'ECM';
|
||||||
|
|
||||||
constructor(public router: Router) {
|
constructor(public router: Router) {
|
||||||
@@ -67,4 +70,13 @@ export class LoginDemoComponent {
|
|||||||
this.providers = undefined;
|
this.providers = undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
validateForm(event: any) {
|
||||||
|
let values = event.values;
|
||||||
|
if (values.controls['username'].value === 'invalidUsername') {
|
||||||
|
this.alfrescologin.addCustomError('username', 'the username is in blacklist');
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user