Guest User

Untitled

a guest
Jan 14th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. onSubmit(name: string, pass:string): void {
  2. name = name.trim();
  3. if (!name) { return; }
  4. let user: any = {
  5. name: null,
  6. pass: null
  7. };
  8. user.name = {value: name};
  9. user.pass = { "": pass};
  10. console.log('Json from the form ' +JSON.stringify(user));
  11. this.UserService.login(user)
  12. .subscribe(user => {
  13. console.log('subscribed to login function' + JSON.stringify(this.user));
  14. });
  15. }
  16.  
  17. login (user: User): Observable<User> {
  18. const url = `${this.mainUrl}/user/login?_format=json`;
  19. const postReturn = this.http.post(url, user, httpHaljson);
  20. console.log('Login return from the user service' + JSON.stringify(postReturn));
  21. return postReturn
  22. }
  23.  
  24. const httpHaljson = {
  25. headers: new HttpHeaders({
  26. "X-CSRF-Token": "Qfnczb1SUnvOAsEy0A_xuGp_rkompgO2oTkCBOSEItM",
  27. "Authorization": "Basic Qfnczb1SUnvOAsEy0A_xuGp_rkompgO2oTkCBOSEItM", // encoded user/pass - this is admin/123qwe
  28. // "Content-Type": "application/hal+json"
  29. "Content-Type": "application/json"
  30. })
  31. };
  32.  
  33. {"_isScalar":false,"source":{"_isScalar":false,"source":
  34.  
  35. {"_isScalar":false,"source":{"_isScalar":true,"value":
  36.  
  37. {"url":"http://drupal.dd:8083/user/login?_format=json","body":{"name":
  38.  
  39. {"value":"asd"},"pass":
  40.  
  41. {"":"123"}},"reportProgress":false,"withCredentials":false,"responseType":"
  42.  
  43. json","method":"POST","headers":{"normalizedNames":
  44.  
  45. {},"lazyUpdate":null},"params":{"updates":null,"cloneFrom":null,"encoder":
  46.  
  47. {},"map":null},"urlWithParams":"http://drupal.dd:8083/user/login?
  48.  
  49. _format=json"},"scheduler":null},"operator":{"concurrent":1}},"operator":
  50.  
  51. {}},"operator":{}}
Add Comment
Please, Sign In to add comment