161f790939f11765fa43037d713d4036.json 10 KB
Newer Older
1
{"ast":null,"code":"var _jsxFileName = \"C:\\\\Users\\\\Bruger\\\\Desktop\\\\Web-projects\\\\pipit\\\\client\\\\src\\\\components\\\\login\\\\signIn\\\\SignIn.jsx\",\n    _s = $RefreshSig$();\n\nimport React, { useState } from 'react';\nimport { useOktaAuth } from '@okta/okta-react';\nimport \"./SignIn.css\";\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\n\nconst SignIn = () => {\n  _s();\n\n  const [isActive, setIsActive] = useState(false);\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: \"signInPage-content\",\n    children: /*#__PURE__*/_jsxDEV(\"div\", {\n      className: \"signInForm-container\",\n      children: /*#__PURE__*/_jsxDEV(\"div\", {\n        className: \"signInForm\",\n        children: [/*#__PURE__*/_jsxDEV(\"h2\", {\n          children: \"Sign in\"\n        }, void 0, false, {\n          fileName: _jsxFileName,\n          lineNumber: 44,\n          columnNumber: 11\n        }, this), /*#__PURE__*/_jsxDEV(\"form\", {\n          onSubmit: handleSubmit,\n          children: [/*#__PURE__*/_jsxDEV(\"label\", {\n            children: [\"Email:\", /*#__PURE__*/_jsxDEV(\"input\", {\n              id: \"username\",\n              type: \"text\",\n              value: username,\n              onChange: handleUsernameChange\n            }, void 0, false, {\n              fileName: _jsxFileName,\n              lineNumber: 48,\n              columnNumber: 15\n            }, this)]\n          }, void 0, true, {\n            fileName: _jsxFileName,\n            lineNumber: 46,\n            columnNumber: 13\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: 55,\n              columnNumber: 15\n            }, this)]\n          }, void 0, true, {\n            fileName: _jsxFileName,\n            lineNumber: 53,\n            columnNumber: 13\n          }, this), /*#__PURE__*/_jsxDEV(\"button\", {\n            className: \"formSubmitButton\",\n            type: \"submit\",\n            children: [\"Sign in\\xA0\\xA0\", /*#__PURE__*/_jsxDEV(FontAwesomeIcon, {\n              icon: \"sign-in-alt\"\n            }, void 0, false, {\n              fileName: _jsxFileName,\n              lineNumber: 62,\n              columnNumber: 15\n            }, this)]\n          }, void 0, true, {\n            fileName: _jsxFileName,\n            lineNumber: 60,\n            columnNumber: 13\n          }, this)]\n        }, void 0, true, {\n          fileName: _jsxFileName,\n          lineNumber: 45,\n          columnNumber: 11\n        }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n          className: \"sign-up-prompt\",\n          children: /*#__PURE__*/_jsxDEV(\"span\", {\n            children: [\"Dont have an account yet?\\xA0\", /*#__PURE__*/_jsxDEV(\"a\", {\n              children: \"Sign up\"\n            }, void 0, false, {\n              fileName: _jsxFileName,\n              lineNumber: 67,\n              columnNumber: 15\n            }, this)]\n          }, void 0, true, {\n            fileName: _jsxFileName,\n            lineNumber: 66,\n            columnNumber: 13\n          }, this)\n        }, void 0, false, {\n          fileName: _jsxFileName,\n          lineNumber: 65,\n          columnNumber: 11\n        }, this)]\n      }, void 0, true, {\n        fileName: _jsxFileName,\n        lineNumber: 43,\n        columnNumber: 9\n      }, this)\n    }, void 0, false, {\n      fileName: _jsxFileName,\n      lineNumber: 42,\n      columnNumber: 7\n    }, this)\n  }, void 0, false, {\n    fileName: _jsxFileName,\n    lineNumber: 41,\n    columnNumber: 5\n  }, this);\n};\n\n_s(SignIn, \"lI16YEvaR6FfIn7A8ugWf9zUgKo=\", false, function () {\n  return [useOktaAuth];\n});\n\n_c = SignIn;\nexport default SignIn;\n\nvar _c;\n\n$RefreshReg$(_c, \"SignIn\");","map":{"version":3,"sources":["C:/Users/Bruger/Desktop/Web-projects/pipit/client/src/components/login/signIn/SignIn.jsx"],"names":["React","useState","useOktaAuth","FontAwesomeIcon","SignIn","isActive","setIsActive","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,cAAP;AACA,SAASC,eAAT,QAAgC,gCAAhC;;;AAEA,MAAMC,MAAM,GAAG,MAAM;AAAA;;AACnB,QAAM,CAACC,QAAD,EAAWC,WAAX,IAA0BL,QAAQ,CAAC,KAAD,CAAxC;AAEA,QAAM;AAAEM,IAAAA;AAAF,MAAeL,WAAW,EAAhC;AACA,QAAM,CAACM,YAAD,EAAeC,eAAf,IAAkCR,QAAQ,EAAhD;AACA,QAAM,CAACS,QAAD,EAAWC,WAAX,IAA0BV,QAAQ,CAAC,EAAD,CAAxC;AACA,QAAM,CAACW,QAAD,EAAWC,WAAX,IAA0BZ,QAAQ,CAAC,EAAD,CAAxC;;AAEA,QAAMa,YAAY,GAAIC,CAAD,IAAO;AAC1BA,IAAAA,CAAC,CAACC,cAAF;AAEAT,IAAAA,QAAQ,CAACU,qBAAT,CAA+B;AAAEP,MAAAA,QAAF;AAA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HZ;AAAA;AAAA;AAAA;AAAA,oBAFF;AAAA;AAAA;AAAA;AAAA;AAAA,kBARF,eAeE;AAAQ,YAAA,SAAS,EAAC,kBAAlB;AAAqC,YAAA,IAAI,EAAC,QAA1C;AAAA,uDAEE,QAAC,eAAD;AAAiB,cAAA,IAAI,EAAC;AAAtB;AAAA;AAAA;AAAA;AAAA,oBAFF;AAAA;AAAA;AAAA;AAAA;AAAA,kBAfF;AAAA;AAAA;AAAA;AAAA;AAAA,gBAFF,eAsBE;AAAK,UAAA,SAAS,EAAC,gBAAf;AAAA,iCACE;AAAA,qEACE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBADF;AAAA;AAAA;AAAA;AAAA;AAAA;AADF;AAAA;AAAA;AAAA;AAAA,gBAtBF;AAAA;AAAA;AAAA;AAAA;AAAA;AADF;AAAA;AAAA;AAAA;AAAA;AADF;AAAA;AAAA;AAAA;AAAA,UADF;AAkCD,CApED;;GAAMzB,M;UAGiBF,W;;;KAHjBE,M;AAqEN,eAAeA,MAAf","sourcesContent":["import React, { useState } from 'react';\r\nimport { useOktaAuth } from '@okta/okta-react';\r\nimport \"./SignIn.css\"\r\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome'\r\n\r\nconst SignIn = () => {\r\n  const [isActive, setIsActive] = useState(false)\r\n\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=\"signInPage-content\">\r\n      <div className=\"signInForm-container\">\r\n        <div className=\"signInForm\">\r\n          <h2>Sign in</h2>\r\n          <form onSubmit={handleSubmit}>\r\n            <label>\r\n              Email:\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;&nbsp;\r\n              <FontAwesomeIcon icon=\"sign-in-alt\"></FontAwesomeIcon>\r\n            </button>\r\n          </form>\r\n          <div className=\"sign-up-prompt\">\r\n            <span>Dont have an account yet?&nbsp;\r\n              <a>Sign up</a>\r\n            </span>\r\n          </div>\r\n        </div>\r\n      </div>\r\n    </div>\r\n  );\r\n};\r\nexport default SignIn;\r\n"]},"metadata":{},"sourceType":"module"}