Advertisement
Guest User

Untitled

a guest
Mar 21st, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. createUser({ body }, res) {
  2. auth.createUser({
  3. email: body.email,
  4. password: body.password,
  5. displayName: body.displayName || '',
  6. photoURL: body.photoURL || DEFAULT_PHOTO_URL,
  7. })
  8. .then((userRecord) => {
  9. console.log('Successfully created new user:', userRecord);
  10. res.send(userRecord);
  11. })
  12. .catch((error) => {
  13. console.log('Error creating new user:', error);
  14. res.send(error);
  15. });
  16. }
  17.  
  18. createUser(properties: Object): Observable<any> {
  19. const body = JSON.stringify(properties);
  20. const url = 'api/user';
  21. const headers = new Headers({ 'Content-Type': 'application/json' });
  22. const options = new RequestOptions({ headers: headers });
  23. return this.http
  24. .post(url, body, options)
  25. .map((res: Response) => res.json())
  26. .catch((error: any) => Observable.throw(error.json()));
  27. }
  28.  
  29. registerWithEmailAndPassword(): void {
  30. const properties = {
  31. 'displayName': this.registerForm.get('firstname').value.toString() + ' ' + this.registerForm.get('lastname').value.toString(),
  32. 'email': this.registerForm.get('email').value.toString(),
  33. 'password': this.registerForm.get('password').value.toString()
  34. };
  35. this.authService.createUser(properties).subscribe(
  36. res => {
  37. console.log('res: ', res);
  38. }, error => {
  39. console.error('error: ', error);
  40. }
  41. );
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement