Skip to content
Draft
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
2 changes: 2 additions & 0 deletions frontend/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
VITE_OIDC_ISSUER_URL=https://oidc.hpi.de
VITE_OIDC_CLIENT_ID=
42 changes: 42 additions & 0 deletions frontend/package-lock.json

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

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@emotion/styled": "^11.8.1",
"@mui/icons-material": "^5.8.2",
"@mui/material": "^5.8.2",
"oidc-client-ts": "^2.0.5",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-query": "^3.39.0",
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { useQuery } from 'react-query';
import { Link, Route, Switch } from 'wouter';
import { useState } from 'react';
import { Button, Container, Stack, TextField, Typography } from '@mui/material';
import AuthCodeReceiver from './auth/AuthCodeReceiver';
import LoginPage from './auth/LoginPage';

type PollPageProps = {
params: { code: string };
Expand Down Expand Up @@ -64,6 +66,8 @@ function App() {

<Switch>
<Route path='/poll/:code' component={PollPage} />
<Route path='/auth/callback' component={AuthCodeReceiver} />
<Route path='/auth/login' component={LoginPage} />
<Route path='/' component={HomePage} />
</Switch>
</Container>
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/auth/AuthCodeReceiver.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { DefaultParams, RouteComponentProps, RouteProps } from "wouter";

export default function AuthCodeReceiver(props: RouteComponentProps<DefaultParams>) {
const params = new URLSearchParams(window.location.search);
return <div>{params.get("code")}</div>;
}
10 changes: 10 additions & 0 deletions frontend/src/auth/LoginPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Button, Stack } from "@mui/material";
import { userManager } from "./userManager";

export default function LoginPage() {
return <Stack>
<Button onClick={() => {
userManager.signinRedirect();
}}>Log In</Button>
</Stack>
}
9 changes: 9 additions & 0 deletions frontend/src/auth/userManager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { UserManager, UserManagerSettings } from "oidc-client-ts";

const settings: UserManagerSettings = {
authority: import.meta.env.VITE_OIDC_ISSUER_URL,
client_id: import.meta.env.VITE_OIDC_CLIENT_ID,
redirect_uri: window.location.origin + "/auth/callback",
response_type: "code",
};
export const userManager = new UserManager(settings);