1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-23 01:39:36 +01:00
onion/js/sources/user_source.js
Brett Sun 7014514654 Use UrlResolver to resolve api urls based on white labelling rather than updating ApiUrl's export
Keeping an export constant is more predictable and less surprising for
most people.
2016-06-14 17:58:00 +02:00

37 lines
826 B
JavaScript

'use strict';
import UserActions from '../actions/user_actions';
import requests from '../utils/requests';
const UserSource = {
lookupCurrentUser: {
remote() {
return requests.get('user');
},
local(state) {
return !Object.keys(state.currentUser).length ? state : {};
},
success: UserActions.successFetchCurrentUser,
error: UserActions.errorCurrentUser,
shouldFetch(state, invalidateCache) {
return invalidateCache || !Object.keys(state.currentUser).length;
}
},
performLogoutCurrentUser: {
remote() {
return requests.get('users_logout');
},
success: UserActions.successLogoutCurrentUser,
error: UserActions.errorCurrentUser
}
};
export default UserSource;