Advertisement
Guest User

Untitled

a guest
May 24th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. //import { Subject } from 'rxjs/Subject';
  2. //import { Observable } from 'rxjs/Observable';
  3. //import * as io from 'socket.io-client';
  4. import {Http, Headers} from '@angular/http';
  5. import {Inject} from "@angular/core";
  6. import map = require("core-js/fn/array/map");
  7.  
  8. import 'rxjs/add/operator/map';
  9. import {bindRenderText} from "@angular/compiler/src/view_compiler/property_binder";
  10.  
  11. export class LoginService{
  12. public isLogin: boolean;
  13. public isInLogin: boolean;
  14. public lePseudo: string;
  15.  
  16. constructor(@Inject(Http) private http:Http){
  17.  
  18. }
  19.  
  20. getUser(pseudo,password){
  21.  
  22. let newUser={
  23. pseudo : pseudo,
  24. password : password
  25. }
  26.  
  27. var headers = new Headers();
  28.  
  29. headers.append('Content-Type', 'application/json');
  30. //this.isInLogin = true;
  31. this.http.post('http://localhost:3000/login/getUser/', JSON.stringify(newUser), {headers})
  32. .subscribe(
  33. data => {
  34. console.log("biiiiiiiiiiiiiiiiiiiii "+newUser.pseudo);
  35. console.log("biiiiiiiiiiiiiiiiiiiii "+data.json());
  36. if(data.json()){
  37. this.lePseudo = newUser.pseudo;
  38. this.isLogin = true;
  39. console.log("affiche moi getUser isloggin: " + this.isLogin);
  40.  
  41. return this.isLogin;
  42. }else {
  43. this.lePseudo = "Pseudo Pas definit";
  44. this.isLogin = false;
  45. console.log("affiche moi getUser isloggin: " + this.isLogin);
  46. return this.isLogin;
  47. }
  48.  
  49. }
  50. );
  51.  
  52. console.log("return this.isLogin : "+this.isLogin);
  53. return this.isLogin;
  54. }
  55. /*
  56. isTrue(pseudo,password){
  57. this.getUser(pseudo,password);
  58. console.log("affiche moi ce putin de isloggin: " + this.isLogin);
  59. return this.isLogin;
  60. }
  61.  
  62. monPseudo(){
  63. console.log("affiche moi ce putin de pseudo: " + this.lePseudo);
  64. return this.lePseudo;
  65. }
  66. */
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement