Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- signInUser(email: string, password: string) {
- return new Promise(
- (resolve, reject) => {
- firebase.auth().signInWithEmailAndPassword(email, password).then(
- () => {
- this.setOnlineState(true);
- resolve();
- },
- (error) => {
- reject(error);
- }
- );
- }
- );
- }
- signOutUser() {
- this.setOnlineState(false);
- firebase.auth().signOut();
- }
- setOnlineState(state: boolean) {
- const currentUser = firebase.auth().currentUser;
- firebase.database().ref("users/" + currentUser.uid).update({ onlineState: state });
- }
- window.onbeforeunload : (e) => {
- this.setOnlineState(false);
- };
Add Comment
Please, Sign In to add comment