andoncloud-sdk 1.1.6 → 1.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20490,16 +20490,37 @@ var LoginForm = function LoginForm(_ref) {
20490
20490
  setPassword = _useState2[1];
20491
20491
 
20492
20492
  var history = reactRouterDom.useHistory();
20493
+
20494
+ var authorizeUser = function authorizeUser(credentials) {
20495
+ try {
20496
+ return Promise.resolve(sessionStore.authorize(_extends$1({
20497
+ scope: scope
20498
+ }, credentials), storeSession)).then(function (session) {
20499
+ if (session) {
20500
+ if (onSuccess && typeof onSuccess === "function") {
20501
+ onSuccess(session);
20502
+ }
20503
+
20504
+ setPassword("");
20505
+ history.push(redirectPath);
20506
+ } else if (onFailure && typeof onFailure === "function") {
20507
+ onFailure();
20508
+ }
20509
+ });
20510
+ } catch (e) {
20511
+ return Promise.reject(e);
20512
+ }
20513
+ };
20514
+
20493
20515
  React.useEffect(function () {
20494
20516
  onscan.attachTo(document, {
20495
20517
  suffixKeyCodes: [13],
20496
20518
  reactToPaste: true,
20497
20519
  onScan: function onScan(sCode, _) {
20498
- console.log("logging in with code: " + sCode);
20499
- sessionStore.authorize({
20520
+ void authorizeUser({
20500
20521
  username: "code",
20501
20522
  password: sCode
20502
- }, storeSession);
20523
+ });
20503
20524
  }
20504
20525
  });
20505
20526
  return function () {
@@ -20518,22 +20539,11 @@ var LoginForm = function LoginForm(_ref) {
20518
20539
  var handleSubmit = function handleSubmit(event) {
20519
20540
  try {
20520
20541
  event.preventDefault();
20521
- return Promise.resolve(sessionStore.authorize({
20522
- scope: scope,
20542
+ void authorizeUser({
20523
20543
  username: username,
20524
20544
  password: password
20525
- }, storeSession)).then(function (session) {
20526
- if (session) {
20527
- if (onSuccess && typeof onSuccess === "function") {
20528
- onSuccess(session);
20529
- }
20530
-
20531
- setPassword("");
20532
- history.push(redirectPath);
20533
- } else if (onFailure && typeof onFailure === "function") {
20534
- onFailure();
20535
- }
20536
20545
  });
20546
+ return Promise.resolve();
20537
20547
  } catch (e) {
20538
20548
  return Promise.reject(e);
20539
20549
  }