0eaf3cd11f67ba47fff9c2a579e2a9fe.json 7.67 KB
Newer Older
1
{"ast":null,"code":"var _jsxFileName = \"C:\\\\Users\\\\Bruger\\\\Desktop\\\\Web-projects\\\\pipit\\\\client\\\\src\\\\components\\\\login\\\\signInForm\\\\SignInForm.jsx\",\n    _s = $RefreshSig$();\n\nimport React, { useState } from 'react';\nimport { useOktaAuth } from '@okta/okta-react';\nimport \"./SignInForm.css\";\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\n\nconst SignInForm = () => {\n  _s();\n\n  const {\n    oktaAuth\n  } = useOktaAuth();\n  const [sessionToken, setSessionToken] = useState();\n  const [username, setUsername] = useState('');\n  const [password, setPassword] = useState('');\n\n  const handleSubmit = e => {\n    e.preventDefault();\n    oktaAuth.signInWithCredentials({\n      username,\n      password\n    }).then(res => {\n      const sessionToken = res.sessionToken;\n      setSessionToken(sessionToken); // sessionToken is a one-use token, so make sure this is only called once\n\n      oktaAuth.signInWithRedirect({\n        sessionToken,\n        originalUri: '/home'\n      });\n    }).catch(err => console.log('Found an error', err));\n  };\n\n  const handleUsernameChange = e => {\n    setUsername(e.target.value);\n  };\n\n  const handlePasswordChange = e => {\n    setPassword(e.target.value);\n  };\n\n  if (sessionToken) {\n    // Hide form while sessionToken is converted into id/access tokens\n    return null;\n  }\n\n  return /*#__PURE__*/_jsxDEV(\"div\", {\n    className: \"loginForm\",\n    children: /*#__PURE__*/_jsxDEV(\"form\", {\n      onSubmit: handleSubmit,\n      children: [/*#__PURE__*/_jsxDEV(\"label\", {\n        children: [\"Username:\", /*#__PURE__*/_jsxDEV(\"input\", {\n          id: \"username\",\n          type: \"text\",\n          value: username,\n          onChange: handleUsernameChange\n        }, void 0, false, {\n          fileName: _jsxFileName,\n          lineNumber: 43,\n          columnNumber: 11\n        }, this)]\n      }, void 0, true, {\n        fileName: _jsxFileName,\n        lineNumber: 41,\n        columnNumber: 9\n      }, this), /*#__PURE__*/_jsxDEV(\"label\", {\n        children: [\"Password:\", /*#__PURE__*/_jsxDEV(\"input\", {\n          id: \"password\",\n          type: \"password\",\n          value: password,\n          onChange: handlePasswordChange\n        }, void 0, false, {\n          fileName: _jsxFileName,\n          lineNumber: 50,\n          columnNumber: 11\n        }, this)]\n      }, void 0, true, {\n        fileName: _jsxFileName,\n        lineNumber: 48,\n        columnNumber: 9\n      }, this), /*#__PURE__*/_jsxDEV(\"button\", {\n        className: \"formSubmitButton\",\n        type: \"submit\",\n        children: [\"Sign in\\xA0\", /*#__PURE__*/_jsxDEV(FontAwesomeIcon, {\n          icon: \"arrow-right\"\n        }, void 0, false, {\n          fileName: _jsxFileName,\n          lineNumber: 57,\n          columnNumber: 11\n        }, this)]\n      }, void 0, true, {\n        fileName: _jsxFileName,\n        lineNumber: 55,\n        columnNumber: 9\n      }, this)]\n    }, void 0, true, {\n      fileName: _jsxFileName,\n      lineNumber: 40,\n      columnNumber: 7\n    }, this)\n  }, void 0, false, {\n    fileName: _jsxFileName,\n    lineNumber: 39,\n    columnNumber: 5\n  }, this);\n};\n\n_s(SignInForm, \"bxx9XPyVMV5w7k/pmF819NCII9M=\", false, function () {\n  return [useOktaAuth];\n});\n\n_c = SignInForm;\nexport default SignInForm;\n\nvar _c;\n\n$RefreshReg$(_c, \"SignInForm\");","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/src/components/login/signInForm/SignInForm.jsx"],"names":["React","useState","useOktaAuth","FontAwesomeIcon","SignInForm","oktaAuth","sessionToken","setSessionToken","username","setUsername","password","setPassword","handleSubmit","e","preventDefault","signInWithCredentials","then","res","signInWithRedirect","originalUri","catch","err","console","log","handleUsernameChange","target","value","handlePasswordChange"],"mappings":";;;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,QAAgC,OAAhC;AACA,SAASC,WAAT,QAA4B,kBAA5B;AACA,OAAO,kBAAP;AACA,SAASC,eAAT,QAAgC,gCAAhC;;;AAEA,MAAMC,UAA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,MADrB;AAEE,UAAA,KAAK,EAAEJ,QAFT;AAGE,UAAA,QAAQ,EAAEgB;AAHZ;AAAA;AAAA;AAAA;AAAA,gBAFF;AAAA;AAAA;AAAA;AAAA;AAAA,cADF,eAQE;AAAA,6CAEE;AACE,UAAA,EAAE,EAAC,UADL;AACgB,UAAA,IAAI,EAAC,UADrB;AAEE,UAAA,KAAK,EAAEd,QAFT;AAGE,UAAA,QAAQ,EAAEiB;AAHZ;AAAA;AAAA;AAAA;AAAA,gBAFF;AAAA;AAAA;AAAA;AAAA;AAAA,cARF,eAeE;AAAQ,QAAA,SAAS,EAAC,kBAAlB;AAAqC,QAAA,IAAI,EAAC,QAA1C;AAAA,+CAEE,QAAC,eAAD;AAAiB,UAAA,IAAI,EAAC;AAAtB;AAAA;AAAA;AAAA;AAAA,gBAFF;AAAA;AAAA;AAAA;AAAA;AAAA,cAfF;AAAA;AAAA;AAAA;AAAA;AAAA;AADF;AAAA;AAAA;AAAA;AAAA,UADF;AAwBD,CAxDD;;GAAMvB,U;UACiBF,W;;;KADjBE,U;AAyDN,eAAeA,UAAf","sourcesContent":["import React, { useState } from 'react';\r\nimport { useOktaAuth } from '@okta/okta-react';\r\nimport \"./SignInForm.css\"\r\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome'\r\n\r\nconst SignInForm = () => {\r\n  const { oktaAuth } = useOktaAuth();\r\n  const [sessionToken, setSessionToken] = useState();\r\n  const [username, setUsername] = useState('');\r\n  const [password, setPassword] = useState('');\r\n\r\n  const handleSubmit = (e) => {\r\n    e.preventDefault();\r\n\r\n    oktaAuth.signInWithCredentials({ username, password })\r\n      .then(res => {\r\n        const sessionToken = res.sessionToken;\r\n        setSessionToken(sessionToken);\r\n        // sessionToken is a one-use token, so make sure this is only called once\r\n        oktaAuth.signInWithRedirect({ sessionToken, originalUri: '/home' });\r\n      })\r\n      .catch(err => console.log('Found an error', err));\r\n  };\r\n\r\n  const handleUsernameChange = (e) => {\r\n    setUsername(e.target.value);\r\n  };\r\n\r\n  const handlePasswordChange = (e) => {\r\n    setPassword(e.target.value);\r\n  };\r\n\r\n  if (sessionToken) {\r\n    // Hide form while sessionToken is converted into id/access tokens\r\n    return null;\r\n  }\r\n\r\n  return (\r\n    <div className=\"loginForm\">\r\n      <form onSubmit={handleSubmit}>\r\n        <label>\r\n          Username:\r\n          <input\r\n            id=\"username\" type=\"text\"\r\n            value={username}\r\n            onChange={handleUsernameChange} />\r\n        </label>\r\n        <label>\r\n          Password:\r\n          <input\r\n            id=\"password\" type=\"password\"\r\n            value={password}\r\n            onChange={handlePasswordChange} />\r\n        </label>\r\n        <button className=\"formSubmitButton\" type=\"submit\">\r\n          Sign in&nbsp;\r\n          <FontAwesomeIcon icon=\"arrow-right\"></FontAwesomeIcon>\r\n        </button>\r\n      </form>\r\n    </div>\r\n  );\r\n};\r\nexport default SignInForm;\r\n"]},"metadata":{},"sourceType":"module"}