Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 131 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
"author": "RespiraWorks",
"license": "Apache2",
"dependencies": {
"@auth0/auth0-react": "^1.10.2",
"axios": "^0.26.1",
"bootstrap": "^5.1.3",
"cookie-parser": "^1.4.6",
"core-js": "^3.22.0",
"cors": "^2.8.5",
"dateformat": "^5.0.3",
"debug": "^4.3.4",
"dotenv": "^16.0.0",
"dotenv": "^16.0.1",
"express": "^4.17.3",
"express-fileupload": "^1.3.1",
"file-saver": "^2.0.5",
Expand Down
6 changes: 6 additions & 0 deletions src/client/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import DataFileTable from './pages/data-file-table';
import UploadFile from './pages/upload-file';
import DataSet from './pages/dataset';
import NotFound from './pages/notfound';
import LoginButton from './login';
import LogoutButton from './logout';
import Profile from './profile';

export default function App() {
return (
Expand All @@ -17,6 +20,9 @@ export default function App() {
<Route path="/dataset" element={<DataSet />} />
<Route path="*" element={<NotFound />} />
</Routes>
<LoginButton/>
Copy link
Member

@martukas martukas Jul 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, the way most websites are, I think, is what users will expect:

  • login page (rather than just button) only visible when you are not logged in, and it redirects to this page whenever you try to access something that requires authorization
  • user profile info probably visible on the navbar on the right (and only when logged in), and logout is an option with a dropdown from that

I guess let's think of Google itself as the template for how people expect these to work?

I think most of this can be done pretty easily within the bootstrap framework. The auto-redirect thing is also abstracted by something like this:
https://github.com/jaredhanson/connect-ensure-login

and I had a few more links to useful things on the ticket #3

<LogoutButton/>
<Profile/>
</BrowserRouter>
</div>
);
Expand Down
15 changes: 13 additions & 2 deletions src/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,22 @@ import App from './App';
import 'core-js/stable';
import 'regenerator-runtime/runtime';

//for Auth0
import { Auth0Provider } from "@auth0/auth0-react";
import LoginButton from './login';


const container = document.getElementById('root');
const root = createRoot(container);

root.render(
<React.StrictMode>
<App />
</React.StrictMode>
<Auth0Provider
domain="dev-gi520dy8.us.auth0.com"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these ok to go into public repository, or should they be part of the .env file? If the latter, please update documentation to explain that additional fields are needed and where to get the values for them.

clientId="LUsIqguU5pbiZ7fWzz2AQKcLZ91luUEt"
redirectUri={window.location.origin}
>
<App />
</Auth0Provider>
</React.StrictMode>
);
10 changes: 10 additions & 0 deletions src/client/login.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { useAuth0 } from "@auth0/auth0-react";
import React from "react";

const LoginButton = () => {
const { loginWithRedirect } = useAuth0();

return <button onClick={() => loginWithRedirect()}>Log In</button>;
};

export default LoginButton;
14 changes: 14 additions & 0 deletions src/client/logout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { useAuth0 } from "@auth0/auth0-react";
import React from "react";

const LogoutButton = () => {
const { logout } = useAuth0();

return (
<button onClick={() => logout({ returnTo: window.location.origin })}>
Log Out
</button>
);
};

export default LogoutButton;
Loading