Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ngOnInit(): void {
- firebase.init({
- persist: true,
- storageBucket: 'gs://**************/',
- onAuthStateChanged: (data: any) => {
- console.log(JSON.stringify(data))
- if (data.loggedIn) {
- BackendService.token = data.user.uid;
- }
- else {
- BackendService.token = "";
- }
- }
- }).then(
- function (instance) {
- console.log("firebase.init done");
- },
- function (error) {
- console.log("firebase.init error: " + error);
- }
- );
- firebase.keepInSync(
- "/users", // which path in your Firebase needs to be kept in sync?
- true // set to false to disable this feature again
- ).then(
- function () {
- console.log("firebase.keepInSync is ON for /users");
- },
- function (error) {
- console.log("firebase.keepInSync error: " + error);
- }
- );
- login(user: User) {
- return firebase.login({
- type: firebase.LoginType.PASSWORD,
- email: user.email,
- password: user.password
- }).then((result: any) => {
- BackendService.token = result.uid;
- return JSON.stringify(result);
- }, (errorMessage: any) => {
- // alert(errorMessage);
- alert('Email address / Password is wrong!!!');
- });
Add Comment
Please, Sign In to add comment