Advertisement
Guest User

Untitled

a guest
Jul 14th, 2017
102
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.  
  18.   constructor(private  credentialService: CredentialService) {
  19.     this.userCredential = new Credential;
  20.     this.ErrorMassage = 'Error: Username or password is incorrect';
  21.   }
  22.  
  23.   ngOnInit() {
  24.     this.credentialService.getCredentials().then(credential => this.userCredential = credential);
  25.     this.isFormEmpty = false;
  26.     this.uncorrectPassword = false;
  27.   }
  28.  
  29.   login(signum: string, password: string) {
  30.     console.log('signum: '+ signum +" password: "+ password);
  31.     if (this.userCredential.signum == '' || this.userCredential.password == '') {
  32.       this.isFormEmpty = true;
  33.       this.uncorrectPassword = false;
  34.     } else {
  35.       this.userCredential.password = btoa(this.userCredential.password);
  36.       if (this.userCredential.signum != "admin" || atob(atob(this.userCredential.password)) != "start")
  37.       {
  38.         this.uncorrectPassword = true;
  39.       }
  40.     }
  41.   }
  42.  
  43.   onChangeText(){
  44.     this.uncorrectPassword = false;
  45.   }
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement