fix minor issues with login

This commit is contained in:
walljm 2019-09-05 11:43:27 -07:00
parent 5cfc34a1f2
commit f767cb4b85
2 changed files with 13 additions and 6 deletions

View File

@ -1,4 +1,4 @@
{
"printWidth": 120,
"singleQuote": false
"singleQuote": true
}

View File

@ -62,8 +62,8 @@ export class ProfileService {
console.log('Saving the remote profile...');
self.remoteProfile.ref.set(self.localProfile);
console.log(' Finished saving remote profile. ' + self.elapsed(st, new Date()) + 'ms');
self.needsSync = false;
}
self.needsSync = false;
}
poll(self);
@ -80,7 +80,9 @@ export class ProfileService {
this.onLocalStorageLoaded.emit(this.localProfile);
});
this.firebaseAuth.authState.subscribe(state => this.subscribeToRemoteProfile(this.db, state));
this.firebaseAuth.authState.subscribe(state => {
this.subscribeToRemoteProfile(this.db, state);
});
}
addSearchRequestToHistory(qry: string) {
@ -141,6 +143,14 @@ export class ProfileService {
}
subscribeToRemoteProfile(db: AngularFireDatabase, user: firebase.User) {
// if this is a logout.
if (user === null) {
console.log('user signed out from FireBase');
this.remoteProfile = null; // inform the profile service not to bother
this.remoteLoggedIn = false;
return;
}
console.log('subscribeToRemoteProfile');
if (!user || this.firebaseUser) return;
console.log('You got the firebase user.');
@ -208,8 +218,6 @@ export class ProfileService {
authenticate() {
console.log('Authenticating to remote...');
let self = this;
let provider = new firebase.auth.GoogleAuthProvider();
if (this.isWeb) {
this.firebaseAuth.auth.signInWithPopup(provider);
@ -225,7 +233,6 @@ export class ProfileService {
console.log(error);
});
}
this.firebaseAuth.authState.subscribe(state => this.subscribeToRemoteProfile(this.db, state));
this.remoteLoggedIn = true;
}