Advertisement
Guest User

Untitled

a guest
Jul 14th, 2017
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import {Component, Inject, Input, OnInit} from '@angular/core';
  2. import {Credential} from './Credential';
  3. import {CredentialService} from './CredentialService';
  4.  
  5. @Component({
  6.   selector: 'app-login',
  7.   templateUrl: './login.component.html',
  8.   styleUrls: ['login.component.css'],
  9.   providers: [CredentialService]
  10. })
  11. export class LoginComponent implements OnInit {
  12.   userCredential: Credential;
  13.   isFormEmpty: boolean;
  14.   uncorrectPassword: boolean;
  15.   ErrorMassage: string;
  16.  
  17.   constructor(private  credentialService: CredentialService) {
  18.     this.userCredential = new Credential;
  19.     this.ErrorMassage = 'Error: Username or password is incorrect';
  20.   }
  21.  
  22.   ngOnInit() {
  23.     this.credentialService.getCredentials().then(credential => this.userCredential = credential);
  24.     this.isFormEmpty = false;
  25.     this.uncorrectPassword = false;
  26.   }
  27.  
  28.   login(signum: string, password: string) {
  29.     console.log('signum: '+ signum +" password: "+ password);
  30.     if (this.userCredential.signum === '' || this.userCredential.password === '') {
  31.       this.isFormEmpty = true;
  32.       this.uncorrectPassword = false;
  33.     } else {
  34.       if (this.userCredential.signum !== 'admin' || this.userCredential.password !== 'admin')
  35.       {
  36.         this.uncorrectPassword = true;
  37.       }
  38.     }
  39.   }
  40.  
  41.   onChangeText(){
  42.     this.uncorrectPassword = false;
  43.   }
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement