1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-23 01:39:36 +01:00
onion/js/actions/user_actions.js

36 lines
778 B
JavaScript
Raw Normal View History

'use strict';
2015-05-20 16:19:40 +02:00
import alt from '../alt';
import UserFetcher from '../fetchers/user_fetcher';
2015-05-20 16:44:45 +02:00
2015-05-20 16:19:40 +02:00
class UserActions {
constructor() {
this.generateActions(
2015-06-20 16:43:18 +02:00
'updateCurrentUser',
'deleteCurrentUser'
2015-05-20 16:19:40 +02:00
);
}
fetchCurrentUser() {
UserFetcher.fetchOne()
.then((res) => {
this.actions.updateCurrentUser(res.users[0]);
2015-05-20 16:19:40 +02:00
})
.catch((err) => {
console.log(err);
2015-05-20 16:19:40 +02:00
});
}
2015-06-20 16:43:18 +02:00
logoutCurrentUser() {
UserFetcher.logout()
.then(() => {
this.actions.deleteCurrentUser();
})
.catch((err) => {
console.log(err);
});
}
}
2015-05-20 16:19:40 +02:00
export default alt.createActions(UserActions);