Skip to content

Commit

Permalink
feat: Call /signout when signing out
Browse files Browse the repository at this point in the history
  • Loading branch information
kachnitel committed Jan 7, 2020
1 parent 8c9775a commit 29b50df
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app.json.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"ios",
"android"
],
"version": "0.9.1",
"version": "0.9.2",
"orientation": "portrait",
"icon": "./assets/images/icon.png",
"splash": {
Expand Down
12 changes: 8 additions & 4 deletions src/components/SignOutButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ class SignOutButton extends Component {
let auth = new Authentication()
await auth.logoutFromAuth0()

SecureStore.deleteItemAsync('refreshToken')
this.props.ApplicationStore.reset()
this.props.UserStore.reset()
this.props.EventStore.reset()
this._resetApp()

this.props.navigation.navigate('Auth')
}
Expand All @@ -42,6 +39,13 @@ class SignOutButton extends Component {
)
}

_resetApp = async () => {
SecureStore.deleteItemAsync('refreshToken')
await this.props.UserStore.signOut()
this.props.ApplicationStore.reset()
this.props.EventStore.reset()
}

render () {
return (
<Button
Expand Down
4 changes: 4 additions & 0 deletions src/providers/RidersProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ export default class RidersProvider {
return ApiConnection.post('signin', data)
}

signOut = (data) => {
return ApiConnection.post('signout', data)
}

loadFriends = () => {
return ApiConnection.get('api/users/friends')
}
Expand Down
7 changes: 7 additions & 0 deletions src/stores/UserStore.mobx.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ export default class UserStore extends BaseCollectionStore {
: false
}

async signOut () {
this.reset()
return this.provider.signOut({
notificationsToken: await (new PushNotifications()).getToken()
})
}

/**
* Search users by name
*
Expand Down

0 comments on commit 29b50df

Please sign in to comment.