@apulis/group-selector
Version:
change user group at navbar
117 lines (100 loc) • 3.76 kB
JavaScript
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
import { customizedRequest } from '@apulis/request';
var iamRequest = customizedRequest('/iam/api/v1');
var aomRequest = customizedRequest('/apsc-bff/license/api/v1');
export function getCurrentUser() {
return _getCurrentUser.apply(this, arguments);
}
function _getCurrentUser() {
_getCurrentUser = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return iamRequest('/users/current');
case 2:
return _context.abrupt("return", _context.sent);
case 3:
case "end":
return _context.stop();
}
}
}, _callee);
}));
return _getCurrentUser.apply(this, arguments);
}
export function refreshToken() {
return _refreshToken.apply(this, arguments);
}
function _refreshToken() {
_refreshToken = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
_context2.next = 2;
return iamRequest('/refresh');
case 2:
return _context2.abrupt("return", _context2.sent);
case 3:
case "end":
return _context2.stop();
}
}
}, _callee2);
}));
return _refreshToken.apply(this, arguments);
}
export function changeGroup(_x) {
return _changeGroup.apply(this, arguments);
}
function _changeGroup() {
_changeGroup = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(id) {
return regeneratorRuntime.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_context3.next = 2;
return iamRequest('/user-groups/current', {
method: 'POST',
data: {
id: id
}
});
case 2:
return _context3.abrupt("return", _context3.sent);
case 3:
case "end":
return _context3.stop();
}
}
}, _callee3);
}));
return _changeGroup.apply(this, arguments);
}
export function getLicenseInfo() {
return _getLicenseInfo.apply(this, arguments);
}
function _getLicenseInfo() {
_getLicenseInfo = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
return regeneratorRuntime.wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
_context4.next = 2;
return aomRequest('/validate', {
cancelMsg: true
});
case 2:
return _context4.abrupt("return", _context4.sent);
case 3:
case "end":
return _context4.stop();
}
}
}, _callee4);
}));
return _getLicenseInfo.apply(this, arguments);
}