Guest User

Untitled

a guest
Mar 22nd, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. ngOnInit(): void {
  2. firebase.init({
  3. persist: true,
  4. storageBucket: 'gs://**************/',
  5. onAuthStateChanged: (data: any) => {
  6. console.log(JSON.stringify(data))
  7. if (data.loggedIn) {
  8. BackendService.token = data.user.uid;
  9. }
  10. else {
  11. BackendService.token = "";
  12. }
  13. }
  14. }).then(
  15. function (instance) {
  16. console.log("firebase.init done");
  17. },
  18. function (error) {
  19. console.log("firebase.init error: " + error);
  20. }
  21. );
  22. firebase.keepInSync(
  23. "/users", // which path in your Firebase needs to be kept in sync?
  24. true // set to false to disable this feature again
  25. ).then(
  26. function () {
  27. console.log("firebase.keepInSync is ON for /users");
  28. },
  29. function (error) {
  30. console.log("firebase.keepInSync error: " + error);
  31. }
  32. );
  33.  
  34. login(user: User) {
  35. return firebase.login({
  36. type: firebase.LoginType.PASSWORD,
  37. email: user.email,
  38. password: user.password
  39. }).then((result: any) => {
  40. BackendService.token = result.uid;
  41. return JSON.stringify(result);
  42. }, (errorMessage: any) => {
  43. // alert(errorMessage);
  44. alert('Email address / Password is wrong!!!');
  45. });
Add Comment
Please, Sign In to add comment