The main server, and probably only repository in this org.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

141 lines
4.3 KiB

Squashed commit of the following: commit 042130f11c6f807d128e2ffbdb76f4be2170a43f Author: Stian Aune <post@stian-aune.com> Date: Wed Apr 10 22:16:14 2019 +0200 Done? commit 3089c6f8be3135ab1aa2b95b9314a753596714a7 Author: Stian Aune <post@stian-aune.com> Date: Wed Mar 27 22:20:07 2019 +0100 Bugfix + some unit tests bc why not? commit 38f874b5538a7d9563b44d60b2fa881d941defc8 Author: Stian Aune <post@stian-aune.com> Date: Tue Mar 26 22:14:22 2019 +0100 Front page. commit 5bdf2a0c48e0e388bffb53714b0410ebd3f8b8e7 Author: Stian Aune <post@stian-aune.com> Date: Thu Mar 7 21:10:57 2019 +0100 Rename groups and stuff. commit 3130710b198c434fe312ea3123cbe5ba3fb526b7 Merge: 118a21a fa98a0b Author: Stian Aune <post@stian-aune.com> Date: Thu Mar 7 21:06:16 2019 +0100 Merge remote-tracking branch 'origin/master' into webui commit 118a21ad42adaa4968318b1e798a58f0565db849 Author: Stian Aune <post@stian-aune.com> Date: Thu Mar 7 21:06:02 2019 +0100 I can a lot of things. commit 089ee6816986e06e77eff404eaa9f04cda0e4275 Merge: 0a6cc16 f27c0a3 Author: Stian Aune <post@stian-aune.com> Date: Tue Mar 5 22:13:41 2019 +0100 Merge remote-tracking branch 'origin/master' into webui commit 0a6cc16e0fda482c04dd88c658273c2774b50d7a Author: Stian Aune <post@stian-aune.com> Date: Tue Mar 5 22:13:31 2019 +0100 More stuff. commit 1ef2623637f2f7c852edffa7914c2095a990539b Author: Stian Aune <post@stian-aune.com> Date: Sun Mar 3 21:59:23 2019 +0100 Add/remove group. commit 59240ce22d305b2b335dd46bb5f528f720b5eedc Merge: 537e86c e11ba33 Author: Stian Aune <post@stian-aune.com> Date: Sun Mar 3 21:15:06 2019 +0100 Merge remote-tracking branch 'origin/master' into webui commit 537e86cced5ab9b8919aaa0f89b277ed9ecdde27 Author: Stian Aune <post@stian-aune.com> Date: Sun Mar 3 21:14:55 2019 +0100 For reals. commit de5fb0d16ddde159a54ce7bb2af09eb4a87960c2 Author: Stian Aune <post@stian-aune.com> Date: Sun Mar 3 21:14:30 2019 +0100 Modal cleanup + light page. commit 01daa2800085df9799de4890a3574ef405b1ec89 Author: Stian Aune <post@stian-aune.com> Date: Sun Feb 24 00:27:36 2019 +0100 Hmm... commit be2fe56e62a212e2691288f5db0a2d826719689d Merge: 99867a5 22dddc7 Author: Stian Aune <post@stian-aune.com> Date: Sat Feb 23 15:16:07 2019 +0100 Merge remote-tracking branch 'origin/master' into webui commit 99867a5fd680e7bd2489df4a01a5609d1e7867d5 Author: Stian Aune <post@stian-aune.com> Date: Sat Feb 23 15:16:02 2019 +0100 WIP. commit d82bbf53f84ab3c47814e5d586400c34787be4d6 Author: Stian Aune <post@stian-aune.com> Date: Tue Feb 19 21:37:59 2019 +0100 WIP. commit 7ed6d2148dcd991050bbc2ecfaef6fc42a0dc4ce Author: Stian Aune <mail@stian-aune.com> Date: Sun Feb 10 13:30:53 2019 +0100 Stuffs. commit ee9a3d485efcf3cf7308a30e4bea27b97002324e Author: Stian Aune <mail@stian-aune.com> Date: Sun Feb 10 12:29:47 2019 +0100 Bleurgh. commit 59ef68ad8f8ce1e05e81c4322bad52cb319cd716 Author: Stian Aune <post@stian-aune.com> Date: Thu Feb 7 21:15:37 2019 +0100 Thursday night commit. commit ee3ff503427fd86306e88bdd4b857690c38f07f4 Merge: daf071a e644f48 Author: Stian Aune <post@stian-aune.com> Date: Wed Feb 6 22:02:37 2019 +0100 Merge remote-tracking branch 'origin/master' into webui commit daf071a4429f5e0158c88e6b142659b6ad6c851a Author: Stian Aune <post@stian-aune.com> Date: Mon Feb 4 20:56:45 2019 +0100 Rewrote light tests. commit edffa49d18ad07b652e5f9d72bd350bd499144a9 Merge: 83052a2 8c302ec Author: Stian Aune <post@stian-aune.com> Date: Mon Feb 4 20:31:26 2019 +0100 Merge remote-tracking branch 'origin/master' into webui commit 83052a2ab8d2b51c3003417142ba15ce1ed06921 Author: Stian Aune <post@stian-aune.com> Date: Mon Feb 4 20:31:22 2019 +0100 Blah. commit aec6cd0b7d5aa812b907b16e1c65687e94e16866 Merge: e6fefb5 0503f79 Author: Stian Aune <post@stian-aune.com> Date: Tue Jan 29 21:06:24 2019 +0100 Merge remote-tracking branch 'origin/master' into webui commit e6fefb5bd1fc487b32515ee5041cd42b37058d52 Merge: 97f7a78 eca8a30 Author: Stian Aune <post@stian-aune.com> Date: Mon Jan 28 22:44:19 2019 +0100 Merge remote-tracking branch 'origin/master' into webui commit 97f7a78f3f72331996eee63c7623d04272bc1d71 Merge: 195738d 174b818 Author: Stian Aune <post@stian-aune.com> Date: Sun Jan 13 13:20:10 2019 +0100 Merge remote-tracking branch 'origin/master' into webui commit 195738d6eddde94f7ca60a2d9b5ea086a204aa7f Merge: a2f2c2b 2e3e120 Author: Stian Aune <post@stian-aune.com> Date: Sat Jan 12 17:24:00 2019 +0100 Merge remote-tracking branch 'origin/master' into webui commit a2f2c2b0bce7d8f54f851dd14d527763390b0123 Merge: edd629e 9004f2f Author: Stian Aune <post@stian-aune.com> Date: Mon Jan 7 20:58:37 2019 +0100 Merge remote-tracking branch 'origin/master' into webui commit edd629eb395af92b250cef9bb452952eded115aa Author: Stian Aune <post@stian-aune.com> Date: Mon Jan 7 20:58:32 2019 +0100 More stuff. commit 206d5005db09f3a149b9dccf9fff886b44252394 Author: Stian Aune <post@stian-aune.com> Date: Mon Jan 7 19:11:03 2019 +0100 Cleanup.
5 years ago
  1. import React, {useState} from "react";
  2. import {
  3. Button,
  4. Card,
  5. CardBody,
  6. CardFooter,
  7. CardHeader,
  8. Col,
  9. Form,
  10. FormGroup,
  11. Input,
  12. Label,
  13. Nav,
  14. NavItem,
  15. NavLink,
  16. TabPane
  17. } from "reactstrap";
  18. import TabContent from "reactstrap/es/TabContent";
  19. import useAuth from "../../Hooks/auth";
  20. import {onEnter} from "../../Helpers/keys";
  21. export default function LoginForm() {
  22. const {login, register} = useAuth();
  23. const [tab, setTab] = useState(1);
  24. const [loginUser, setLoginUser] = useState("");
  25. const [loginPass, setLoginPass] = useState("");
  26. const [regUser, setRegUser] = useState("");
  27. const [regPass1, setRegPass1] = useState("");
  28. const [regPass2, setRegPass2] = useState("");
  29. return (
  30. <Card className="mt-3">
  31. <CardHeader>Tilgangskontroll</CardHeader>
  32. <CardBody>
  33. <Nav tabs>
  34. <NavItem>
  35. <NavLink className={tab === 1 ? "active" : ""}
  36. onClick={() => setTab(1)}
  37. onKeyDown={onEnter(() => setTab(1))}
  38. tabIndex={0}
  39. >
  40. Innlogging
  41. </NavLink>
  42. </NavItem>
  43. <NavItem>
  44. <NavLink className={tab === 2 ? "active" : ""}
  45. onClick={() => setTab(2)}
  46. onKeyDown={onEnter(() => setTab(2))}
  47. tabIndex={0}
  48. >
  49. Registrering
  50. </NavLink>
  51. </NavItem>
  52. </Nav>
  53. <TabContent activeTab={tab} className="mt-3">
  54. <TabPane tabId={1}>
  55. <Form>
  56. <FormGroup row>
  57. <Label sm={3} for="input-login-user">Brukernavn</Label>
  58. <Col sm={9}>
  59. <Input type="text"
  60. id="input-login-user"
  61. value={loginUser}
  62. onChange={e => setLoginUser(e.target.value)}
  63. />
  64. </Col>
  65. </FormGroup>
  66. <FormGroup row>
  67. <Label sm={3} for="input-login-password">Passord</Label>
  68. <Col sm={9}>
  69. <Input type="password"
  70. id="input-login-password"
  71. value={loginPass}
  72. onChange={e => setLoginPass(e.target.value)}
  73. />
  74. </Col>
  75. </FormGroup>
  76. </Form>
  77. </TabPane>
  78. <TabPane tabId={2}>
  79. <Form>
  80. <FormGroup row>
  81. <Label sm={3} for="input-reg-user">Brukernavn</Label>
  82. <Col sm={9}>
  83. <Input type="text"
  84. id="input-reg-user"
  85. value={regUser}
  86. onChange={e => setRegUser(e.target.value)}
  87. />
  88. </Col>
  89. </FormGroup>
  90. <FormGroup row>
  91. <Label sm={3} for="input-reg-password-1">Passord</Label>
  92. <Col sm={9}>
  93. <Input type="password"
  94. id="input-reg-password-1"
  95. value={regPass1}
  96. onChange={e => setRegPass1(e.target.value)}
  97. />
  98. </Col>
  99. </FormGroup>
  100. <FormGroup row>
  101. <Label sm={3} for="input-reg-password-2">Gjenta passord</Label>
  102. <Col sm={9}>
  103. <Input type="password"
  104. id="input-reg-password-2"
  105. value={regPass2}
  106. onChange={e => setRegPass2(e.target.value)}
  107. />
  108. </Col>
  109. </FormGroup>
  110. </Form>
  111. </TabPane>
  112. </TabContent>
  113. </CardBody>
  114. <CardFooter>
  115. {tab === 1 && <Button color="primary" onClick={() => login(loginUser, loginPass)}>Logg inn</Button>}
  116. {tab === 2 && (
  117. <>
  118. <Button color="primary"
  119. onClick={() => register(regUser, regPass1, regPass2)}
  120. >
  121. Registrer
  122. </Button>
  123. {" "}
  124. <Button color="secondary"
  125. onClick={() => {
  126. setRegUser("");
  127. setRegPass1("");
  128. setRegPass2("");
  129. setTab(1);
  130. }}>
  131. Avbryt
  132. </Button>
  133. </>
  134. )}
  135. </CardFooter>
  136. </Card>
  137. );
  138. }