diff options
Diffstat (limited to 'runtime/ui-react/src/api/UserService.js')
-rw-r--r-- | runtime/ui-react/src/api/UserService.js | 97 |
1 files changed, 49 insertions, 48 deletions
diff --git a/runtime/ui-react/src/api/UserService.js b/runtime/ui-react/src/api/UserService.js index 5fb4aa6b4..bcf46ea64 100644 --- a/runtime/ui-react/src/api/UserService.js +++ b/runtime/ui-react/src/api/UserService.js @@ -22,53 +22,54 @@ */ export default class UserService { - static notLoggedUserName='Anonymous'; - static login() { - return fetch(window.location.pathname + 'restservices/clds/v1/user/getUser', { - method: 'GET', - credentials: 'same-origin' - }) - .then(function (response) { - console.debug("getUser response received, status code:", response.status); - if (response.ok) { - return response.text(); - } else { - console.error("getUser response is nok"); - return UserService.notLoggedUserName; - } - }) - .then(function (data) { - console.info ("User connected:",data) - return data; - }) - .catch(function(error) { - console.warn("getUser error received, user set to: ",UserService.notLoggedUserName); - console.error("getUser error:",error); - return UserService.notLoggedUserName; - }); - } + static notLoggedUserName = 'Anonymous'; - static getUserInfo() { - return fetch(window.location.pathname + 'restservices/clds/v2/clampInformation', { - method: 'GET', - credentials: 'same-origin' - }) - .then(function (response) { - console.debug("getUserInfo response received, status code:", response.status); - if (response.ok) { - return response.json(); - } else { - return {} - } - }) - .then(function (data) { - console.info ("User info received:",data) - return data; - }) - .catch(function(error) { - console.warn("getUserInfo error received, user set to: ",UserService.notLoggedUserName); - console.error("getUserInfo error:",error); - return {}; - }); - } + static login() { + return fetch(window.location.pathname + 'restservices/clds/v1/user/getUser', { + method: 'GET', + credentials: 'same-origin' + }) + .then(function (response) { + console.debug("getUser response received, status code:", response.status); + if (response.ok) { + return response.text(); + } else { + console.error("getUser response is nok"); + return UserService.notLoggedUserName; + } + }) + .then(function (data) { + console.info("User connected:", data) + return data; + }) + .catch(function (error) { + console.warn("getUser error received, user set to: ", UserService.notLoggedUserName); + console.error("getUser error:", error); + return UserService.notLoggedUserName; + }); + } + + static getUserInfo() { + return fetch(window.location.pathname + 'restservices/clds/v2/clampInformation', { + method: 'GET', + credentials: 'same-origin' + }) + .then(function (response) { + console.debug("getUserInfo response received, status code:", response.status); + if (response.ok) { + return response.json(); + } else { + return {} + } + }) + .then(function (data) { + console.info("User info received:", data) + return data; + }) + .catch(function (error) { + console.warn("getUserInfo error received, user set to: ", UserService.notLoggedUserName); + console.error("getUserInfo error:", error); + return {}; + }); + } } |