diff --git a/client/src/App.js b/client/src/App.js index 6af69ab..ed0b1ac 100644 --- a/client/src/App.js +++ b/client/src/App.js @@ -8,6 +8,7 @@ import Media from './pages/Media'; import LoginPage from './pages/Login'; import Panel from './pages/Panel'; import Mobile from './pages/Mobile'; +import Profile from './pages/Profile'; import { clearSession, fetchUser, setSession, logout } from './util/Util'; import { PrivateRoute } from './Routes/Private'; import { useLoginContext } from './Structures/UserContext'; @@ -17,7 +18,8 @@ import Upload from './pages/Upload'; const User = ({user}) => { return (
-

{user.tag}

+

+ {user.tag}
); @@ -104,6 +106,7 @@ function App() { } /> } /> } /> + } /> } /> diff --git a/client/src/css/Profile.css b/client/src/css/Profile.css new file mode 100644 index 0000000..ba4e37b --- /dev/null +++ b/client/src/css/Profile.css @@ -0,0 +1,11 @@ +.profile { + +} + +.token { + background-color: gray; + position: relative; + top: 2vh; + margin: auto; + width: 50%; +} \ No newline at end of file diff --git a/client/src/css/index.css b/client/src/css/index.css index 7a2ac48..1703562 100644 --- a/client/src/css/index.css +++ b/client/src/css/index.css @@ -81,4 +81,11 @@ code { a { color: var(--navy-blue); +} + +code { + background-color: #7777778c; + border-radius: 4px; + padding-left: 4px; + padding-right: 4px; } \ No newline at end of file diff --git a/client/src/pages/Profile.js b/client/src/pages/Profile.js new file mode 100644 index 0000000..356be18 --- /dev/null +++ b/client/src/pages/Profile.js @@ -0,0 +1,60 @@ +import React, { useState } from "react"; +import { useLoginContext } from "../Structures/UserContext"; +import '../css/Profile.css'; + +const Token = ({ user }) => { + + const [token, updateToken] = useState(user?.token); + console.log(user); + + const generateToken = async ({target: button}) => { + + button.disabled = true; + const response = await fetch(`/api/user/token`, { + credentials: 'include' + }); + + button.disabled = true; + + if (response.status !== 200) return; + + const { token } = await response.json(); + updateToken(token); + + }; + + return ( +
+ +

+ The upload token lets you send files directly to the /api/upload endpoint.
+ The token needs to be under the Authorization header. +

+ +
+ {!token ? + : +

{token}

+ } +
+ +
+ ); + +}; + +const Profile = () => { + + const [user] = useLoginContext(); + + return ( +
+ + + +
+ ); + +}; + +export default Profile; \ No newline at end of file diff --git a/client/src/pages/Upload.js b/client/src/pages/Upload.js index 7b9b9b6..ace3229 100644 --- a/client/src/pages/Upload.js +++ b/client/src/pages/Upload.js @@ -56,6 +56,7 @@ const Upload = () => { updateName(event.target.value)}