2 * STANDARD_RIFT_IO_COPYRIGHT
4 import $ from 'jquery';
5 var Utils
= require('utils/utils.js');
6 let API_SERVER
= require('utils/rw.js').getSearchParams(window
.location
).api_server
;
8 let NODE_PORT
= require('utils/rw.js').getSearchParams(window
.location
).api_port
|| ((window
.location
.protocol
== 'https:') ? 8443 : 8000);
9 let DEV_MODE
= require('utils/rw.js').getSearchParams(window
.location
).dev_mode
|| false;
12 HOST
= window
.location
.protocol
+ '//' + window
.location
.hostname
;
18 module
.exports = function(Alt
) {
21 remote: function(state
, user
) {
22 return new Promise(function(resolve
, reject
) {
24 url
: `/user?api_server=${API_SERVER}`,
27 beforeSend
: Utils
.addAuthorizationStub
,
28 success: function(data
, textStatus
, jqXHR
) {
31 }).fail(function(xhr
){
32 //Authentication and the handling of fail states should be wrapped up into a connection class.
33 Utils
.checkAuthentication(xhr
.status
);
34 let msg
= xhr
.responseText
;
35 if(xhr
.errorMessage
) {
36 msg
= xhr
.errorMessage
42 interceptResponse
: interceptResponse({
43 'error': 'There was an error updating the user.'
45 success
: Alt
.actions
.global
.updateUserSuccess
,
46 loading
: Alt
.actions
.global
.showScreenLoader
,
47 error
: Alt
.actions
.global
.handleServerReportedError
50 remote: function(state
, user
) {
52 return new Promise(function(resolve
, reject
) {
54 url
: `/user?api_server=${API_SERVER}`,
57 beforeSend
: Utils
.addAuthorizationStub
,
58 success: function(data
, textStatus
, jqXHR
) {
61 }).fail(function(xhr
){
62 //Authentication and the handling of fail states should be wrapped up into a connection class.
63 Utils
.checkAuthentication(xhr
.status
);
64 let msg
= xhr
.responseText
;
65 if(xhr
.errorMessage
) {
66 msg
= xhr
.errorMessage
72 interceptResponse
: interceptResponse({
73 'error': 'There was an error updating the account.'
75 success
: Alt
.actions
.global
.createUserSuccess
,
76 loading
: Alt
.actions
.global
.showScreenLoader
,
77 error
: Alt
.actions
.global
.handleServerReportedError
82 function interceptResponse (responses
) {
83 return function(data
, action
, args
) {
84 if(responses
.hasOwnProperty(data
)) {