0b04fb848d31e79c26d2a2aa7b93ef9b.json 6.51 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 { 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      });\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(\"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: 40,\n        columnNumber: 9\n      }, this)]\n    }, void 0, true, {\n      fileName: _jsxFileName,\n      lineNumber: 38,\n      columnNumber: 7\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: 47,\n        columnNumber: 9\n      }, this)]\n    }, void 0, true, {\n      fileName: _jsxFileName,\n      lineNumber: 45,\n      columnNumber: 7\n    }, this), /*#__PURE__*/_jsxDEV(\"input\", {\n      id: \"submit\",\n      type: \"submit\",\n      value: \"Submit\"\n    }, void 0, false, {\n      fileName: _jsxFileName,\n      lineNumber: 52,\n      columnNumber: 7\n    }, this)]\n  }, void 0, true, {\n    fileName: _jsxFileName,\n    lineNumber: 37,\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","SignInForm","oktaAuth","sessionToken","setSessionToken","username","setUsername","password","setPassword","handleSubmit","e","preventDefault","signInWithCredentials","then","res","signInWithRedirect","catch","err","console","log","handleUsernameChange","target","value","handlePasswordChange"],"mappings":";;;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,QAAgC,OAAhC;AACA,SAASC,WAAT,QAA4B,kBAA5B;;;AAEA,MAAMC,UAAU,GAAG,MAAM;AAAA;;AACvB,QAAM;AAAEC,IAAAA;AAAF,MAAeF,WAAW,EAAhC;AACA,QAAM,CAACG,YAAD,EAAeC,eAAf,IAAkCL,QAAQ,EAAhD;AACA,QAAM,CAACM,QAAD,EAAWC,WAAX,IAA0BP,QAAQ,CAAC,EAAD,CAAxC;AACA,QAAM,CAACQ,QAAD,EAAWC,WAAX,IAA0BT,QAAQ,CAAC,EAAD,CAAxC;;AAEA,QAAMU,YAAY,GAAIC,CAAD,IAAO;AAC1BA,IAAAA,CAAC,CAACC,cAAF;AAEAT,IAAAA,QAAQ,CAACU,qBAAT,CAA+B;AAAEP,MAA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AAA;AAAA;AAAA;AAAA;AAAA,UADF;AAmBD,CAnDD;;GAAMtB,U;UACiBD,W;;;KADjBC,U;AAoDN,eAAeA,UAAf","sourcesContent":["import React, { useState } from 'react';\r\nimport { useOktaAuth } from '@okta/okta-react';\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 });\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    <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      <input id=\"submit\" type=\"submit\" value=\"Submit\" />\r\n    </form>\r\n  );\r\n};\r\nexport default SignInForm;\r\n"]},"metadata":{},"sourceType":"module"}