1
0
mirror of https://github.com/ascribe/onion.git synced 2024-06-30 13:41:57 +02:00
onion/js/actions/user_actions.js
Tim Daubenschütz 28dfcfa75a Merge remote-tracking branch 'origin/master' into AD-727-missing-redirects-to-login-page
Conflicts:
	js/components/ascribe_detail/edition.js
	js/components/ascribe_forms/form_login.js
	js/components/ascribe_forms/form_signup.js
2015-10-06 16:40:02 +02:00

38 lines
847 B
JavaScript

'use strict';
import alt from '../alt';
import UserFetcher from '../fetchers/user_fetcher';
class UserActions {
constructor() {
this.generateActions(
'updateCurrentUser',
'deleteCurrentUser'
);
}
fetchCurrentUser() {
UserFetcher.fetchOne()
.then((res) => {
this.actions.updateCurrentUser(res.users[0]);
})
.catch((err) => {
console.logGlobal(err);
this.actions.updateCurrentUser({});
});
}
logoutCurrentUser() {
UserFetcher.logout()
.then(() => {
this.actions.deleteCurrentUser();
})
.catch((err) => {
console.logGlobal(err);
});
}
}
export default alt.createActions(UserActions);