inProgress-team / inProgress-team/react-native-meteor
User logged out after loginWithPassword and changing network WIFI/4G
- Dominant language
- JavaScript
- Stars
- 688
- Forks
- 200
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I have created a simple App that connects to a remote server and just do login a user and logout.
When i reload app when user is logged In and change network, everything works well as expected, the server reconnect and the user still exists
After LoginWithPassword and charging the user connected view, when changing Network, the server disconnects and reconnect in a normal way, except that after a few seconds it goes to Login page with user null and every time i click on login, the user is still null and i still get the login page.
When i reload in this case, i have the screen userConnected.
My code is Here :
```
import React, {Component} from 'react';
import { StyleSheet, Text, View, TouchableOpacity} from 'react-native';
import Meteor, { withTracker } from 'react-native-meteor';
type Props = {};
Meteor.connect('wss:XXXX'); //do this only once
class App extends Component {
constructor(){
super();
this.state={
subscribed: false,
}
}
loginUser(){
Meteor.loginWithPassword('hh@hh.mmm', 'qwerty', (err) => {
if (err) {
console.log('Error Login')
}
});
}
logoutUser(){
Meteor.logout();
}
render() {
const {
user, status, loggingIn,
} = this.props;
if (status.connected === false || loggingIn) {
console.log('WE are LOADING')
return(
LOADING!
);
}
if (user === null) {
console.log('WE are not Logged')
return (
LOGIN!
this.loginUser()}>
CONNECT
);
}else {
console.log('WE are logged in')
return(
UserConnected
this.logoutUser()}>
DISCONNECT
);
}
}
}
export default withTracker(params => {
return {
status: Meteor.status(),
user: Meteor.user(),
loggingIn: Meteor.loggingIn(),
};
})(App);
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
```
[Demo_BUG](http://sendvid.com/kwpexvs4)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.