Skip to content

Commit

Permalink
Fix sign in with other account after logout bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Tiffany authored and kfoxb committed Apr 28, 2017
1 parent 5a06ded commit ce48662
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
16 changes: 13 additions & 3 deletions app/SignUp.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,35 @@ export default class SignUp extends Component {
long: position.coords.longitude
};

return AuthAxios({
AuthAxios({
url: `/api/user/location`,
method: 'put',
data: location
})
.then(() => {
console.log('location updated');
})
.catch((err) => {
console.log('location failed to update: ', err);
});
}

_signIn() {
const { navigate } = this.props.navigation;
GoogleSignin.signIn()
.then((user) => {
this.setState({user: user});
return this.saveLocation();
return AuthAxios({
url: '/api/user'
})
})
.then(({data}) => {
this.setState({dbUser: data});
if (!data.created) {
console.log('new user? ', data.created, data);
if (data.created === false) {
navigate('HomePageTabs');
}
this.saveLocation();
})
.catch((err) => {
console.log('Error: ', err);
Expand Down
6 changes: 5 additions & 1 deletion app/SplashScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ export default class SplashScreen extends Component {
{enableHighAccuracy: false, timeout: 20000, maximumAge: 90000000000000}
);
this.watchID = navigator.geolocation.watchPosition((position) => {
this.setState({lastPosition: position}, () => {this.saveLocation()});
this.setState({lastPosition: position}, () => {
if (this.state.user) {
this.saveLocation()
}
});
});
}

Expand Down

0 comments on commit ce48662

Please sign in to comment.