-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add basic auth via a proxy * update linters and run
- Loading branch information
1 parent
464cc7d
commit 92f7eba
Showing
14 changed files
with
212 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,5 +19,5 @@ repos: | |
name: Run ruff | ||
stages: [commit] | ||
language: system | ||
entry: ruff | ||
entry: ruff check | ||
types: [python] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Link } from "react-router-dom"; | ||
|
||
function LogInPage() { | ||
return ( | ||
<Link to="/login" reloadDocument={true}> | ||
Log In | ||
</Link> | ||
); | ||
} | ||
|
||
export default LogInPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { useContext, FC } from "react"; | ||
import { UserContext } from "../contexts/UserContext"; | ||
|
||
import { Navigate } from "react-router-dom"; | ||
|
||
const RequireAuth: FC<{ children: React.ReactElement }> = ({ children }) => { | ||
const user = useContext(UserContext); | ||
|
||
if (user === null) { | ||
return <Navigate to={"/login"} replace />; | ||
} | ||
return children; | ||
}; | ||
|
||
export default RequireAuth; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { createContext } from "react"; | ||
import { User } from "../models"; | ||
import useUser from "../hooks/useUser"; | ||
|
||
const UserContext = createContext<User | null>(null); | ||
|
||
function UserProvider(props: { children: React.ReactNode }) { | ||
const { children } = props; | ||
const user = useUser(); | ||
|
||
return <UserContext.Provider value={user}>{children}</UserContext.Provider>; | ||
} | ||
|
||
export { UserContext, UserProvider }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { useEffect, useState } from "react"; | ||
import axios, { AxiosResponse } from "axios"; | ||
import { User } from "../models"; | ||
|
||
const user_url = "/api/user"; | ||
|
||
function useUser(): User | null { | ||
const [currentUser, setCurrentUser] = useState<User | null>(null); | ||
|
||
useEffect(() => { | ||
axios | ||
.get(user_url) | ||
.then((res: AxiosResponse) => { | ||
// console.log(res.status); | ||
setCurrentUser({ identifier: res.data.user }); | ||
}) | ||
.catch((error) => { | ||
console.log(error.response); | ||
setCurrentUser(null); | ||
}); | ||
}, []); | ||
|
||
return currentUser; | ||
} | ||
|
||
export default useUser; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters