SHARE
TWEET

Untitled

a guest Jun 5th, 2017 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { Component, OnInit } from '@angular/core';
  2. import { LoginService } from '../../services/login/login.service';
  3. import { ChatService }  from '../../services/chat/chat.service';
  4. import { User } from '../../../User';
  5. import { Router } from '@angular/router';
  6. import {initialRouterNavigation} from "@angular/router/src/router_module";
  7. import {ChatComponent} from "../chat/chat.component";
  8. import 'rxjs/add/operator/toPromise';
  9.  
  10. @Component({
  11.     moduleId: module.id,
  12.     selector: 'login',
  13.     templateUrl: 'login.component.html',
  14.     providers: [LoginService,ChatService]
  15. })
  16.  
  17. export class LoginComponent {
  18.     //initialisation de notre classe/modele User/ts
  19.  
  20.     user : User;
  21.     email : string;
  22.     pseudo : string;
  23.     isGood:boolean;
  24.     constructor(private loginService:LoginService, private router:Router){
  25.  
  26.     console.log("yaaaaaaaaaaaaaaaaaaaa ");
  27.     }
  28.  
  29.     isTrue(email,password){
  30.         let newUser={
  31.             email : this.user.email,
  32.             password : this.user.password
  33.         }
  34.         console.log("login comp email: "+email);
  35.  
  36.         this.loginService.getUser(newUser).then(userLogged=>{
  37.             console.log(userLogged.exist);
  38.             if(userLogged.exist){
  39.                 this.router.navigate(['/home',userLogged.pseudo]);
  40.             }else{
  41.                 this.router.navigate([]);
  42.             }
  43.         });
  44.  
  45.     }
  46.     /*
  47.      isTrue(pseudo,password){
  48.      let newUser={
  49.      pseudo : this.user.pseudo,
  50.      password : this.user.password
  51.      }
  52.      console.log("login comp pseudo: "+pseudo);
  53.  
  54.      this.loginService.getUser(newUser).then(logged=>{
  55.      console.log(logged);
  56.      if(logged){
  57.      this.router.navigate(['/profil']);
  58.      }else{
  59.      this.router.navigate([]);
  60.      }
  61.      });
  62.      }
  63.      */
  64.     ngOnInit() {
  65.         this.user = {
  66.             _id: '',
  67.             pseudo: '',
  68.             email: '',
  69.             password: '',
  70.             picture:'',
  71.             bio:'',
  72.             birthday:'',
  73.             exist:true
  74.         }
  75.     }
  76. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top