Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import {Component, Inject, Input, OnInit} from '@angular/core';
- import {Credential} from './Credential';
- import {CredentialService} from './CredentialService';
- @Component({
- selector: 'app-login',
- templateUrl: './login.component.html',
- styleUrls: ['login.component.css'],
- providers: [CredentialService]
- })
- export class LoginComponent implements OnInit {
- userCredential: Credential;
- isFormEmpty: boolean;
- uncorrectPassword: boolean;
- ErrorMassage: string;
- constructor(private credentialService: CredentialService) {
- this.userCredential = new Credential;
- this.ErrorMassage = 'Error: Username or password is incorrect';
- }
- ngOnInit() {
- this.credentialService.getCredentials().then(credential => this.userCredential = credential);
- this.isFormEmpty = false;
- this.uncorrectPassword = false;
- }
- login(signum: string, password: string) {
- console.log('signum: '+ signum +" password: "+ password);
- if (this.userCredential.signum === '' || this.userCredential.password === '') {
- this.isFormEmpty = true;
- this.uncorrectPassword = false;
- } else {
- if (this.userCredential.signum !== 'admin' || this.userCredential.password !== 'admin')
- {
- this.uncorrectPassword = true;
- }
- }
- }
- onChangeText(){
- this.uncorrectPassword = false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement