diff --git a/src/App.js b/src/App.js
index f9a6562..d466c94 100644
--- a/src/App.js
+++ b/src/App.js
@@ -14,6 +14,7 @@ import { UnauthedRoute } from './structures/UnauthedRoute';
import Users from './pages/Users';
import Admin from './pages/Admin';
import TitledPage from './components/TitledPage';
+import Register from './pages/Register';
function App() {
@@ -29,7 +30,7 @@ function App() {
}, []);
const menuItems = [
- { to: '/home', label: 'Home' },
+ { to: '/home', label: 'Home', items: [{ to: '/profile', label: 'Profile', relative: false }] },
{ to: '/users', label: 'Users' },
{ to: '/admin', label: 'Admin' }
];
@@ -38,10 +39,10 @@ function App() {
return (
-
+
-
+
{user ?
@@ -54,34 +55,45 @@ function App() {
: null}
-
-
-
-
-
-
-
- } />
-
-
-
-
- } />
-
-
- } />
-
-
- } />
- } />
-
-
-
+
+
+
+
+
+
+
+
+ } />
+
+
+
+
+
+ } />
+
+
+
+ } />
+
+
+ } />
-
+
+
+ } />
+
+ } />
+
+
+
+
+
-
+
+
+
+
);
diff --git a/src/css/index.css b/src/css/index.css
index 1892507..22d8df7 100644
--- a/src/css/index.css
+++ b/src/css/index.css
@@ -18,6 +18,10 @@
--font-family-mono: monaco, "Consolas", "Lucida Console", monospace;
}
+.clickable {
+ cursor: pointer;
+}
+
a:hover:not(.button){
opacity: 1 !important;
color: #C4C4C4;
diff --git a/src/pages/Login.js b/src/pages/Login.js
index 2d246f6..46f8ab5 100644
--- a/src/pages/Login.js
+++ b/src/pages/Login.js
@@ -25,17 +25,17 @@ const CredentialFields = () => {
if (!username.length || !password.length) return;
const result = await post('/api/login', { username, password });
- console.log(result);
+
if (![200, 302].includes(result.status)) {
setFail(true);
return;
}
- if (!result.data.twoFactor) {
+ if (!result.data?.twoFactor) {
setUser(await fetchUser());
return navigate('/home');
}
- return navigate('/login/verify');
+ return navigate('verify');
};
@@ -43,13 +43,21 @@ const CredentialFields = () => {
+
{fail ?
Invalid credentials
: null}
Log in
-
-
-
+
+
+
+
diff --git a/src/pages/Register.js b/src/pages/Register.js
new file mode 100644
index 0000000..ea401d9
--- /dev/null
+++ b/src/pages/Register.js
@@ -0,0 +1,49 @@
+import React, { useState } from "react";
+import { useNavigate, useSearchParams } from "react-router-dom";
+import { post } from "../util/Util";
+
+// TODO: Make this page look similar to the login page, probably generalise the components
+const Register = () => {
+
+ const [error, setError] = useState();
+ const [params] = useSearchParams();
+ const navigate = useNavigate();
+
+ document.body.classList.add('bg-triangles');
+ const code = params.get('code');
+
+ const submit = async () => {
+ const username = document.getElementById('username').value;
+ const password = document.getElementById('password').value;
+ if (!username.length || !password.length) return;
+
+ const response = await post('/api/register', { username, password, code });
+ if (response.status !== 200) return setError(response.message);
+ navigate('/login');
+ };
+
+ return
+
+
+
+
Register
+
+ {error &&
{error}
}
+
+
+
+
+
+
+
+
;
+
+};
+
+export default Register;
\ No newline at end of file