Skip to content

Commit 7ac3df9

Browse files
committed
Fixed merge auth and db user bug.
1 parent 61b6d89 commit 7ac3df9

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

meetsy/src/components/App/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ class App extends Component {
4747
}
4848
componentDidMount(){
4949
this.props.firebase.auth.onAuthStateChanged(authUser => {
50-
console.log("Out here!");
50+
this.setState({loading: true})
51+
console.log("Out here!", this.state.loading);
5152
if (authUser) {
5253
console.log("In here!");
5354
this.props.firebase.user(authUser.uid)
@@ -67,10 +68,12 @@ class App extends Component {
6768
providerData: authUser.providerData,
6869
...dbUser,
6970
};
71+
console.log("Loading-ul este: " , this.state.loading)
7072
console.log(this.props.firebase.authUser);
7173
this.setState({loading: false})
7274
});
7375
} else {
76+
console.log("Loading-ul este pe callback: ", this.state.loading)
7477
this.setState({loading:false})
7578
}
7679
});

meetsy/src/components/Firebase/firebase.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ class Firebase {
4444
doSignInWithEmailAndPassword = (email, password) =>
4545
this.auth.signInWithEmailAndPassword(email, password);
4646

47-
doSignOut = () => this.auth.signOut();
47+
doSignOut = () => {
48+
this.auth.signOut();
49+
window.location.reload();
50+
}
4851

4952
doPasswordReset = email => this.auth.sendPasswordResetEmail(email);
5053

meetsy/src/components/Session/withAuthorization.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ const withAuthorization = condition => Component => {
1111
this.listener = this.props.firebase.auth.onAuthStateChanged(
1212
authUser => {
1313
if (!condition(authUser)) {
14+
if (!authUser) {
1415
this.props.history.push(ROUTES.SIGN_IN);
16+
}
17+
else {
18+
this.props.history.push(ROUTES.HOME);
19+
}
1520
}
1621
},
1722
);

meetsy/src/components/SignOut/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ const link = {
2020

2121

2222
const SignOutButton = ({ firebase }) => (
23-
<button style={icon} type="button" onClick={firebase.doSignOut}>
24-
<IconSignOut color='white'/>
23+
<Link to={ROUTES.SIGN_IN} style={link} onClick={firebase.doSignOut}>
24+
<button style={icon} type="button">
25+
<IconSignOut color='white' />
2526
</button>
27+
</Link>
2628
);
2729

2830
export default withFirebase(SignOutButton);

0 commit comments

Comments
 (0)