Added authentication handling

This commit is contained in:
Mitchell McCaffrey
2020-04-14 16:05:44 +10:00
parent 5dc6a4ed32
commit 2ceec9cfec
9 changed files with 237 additions and 38 deletions
+25
View File
@@ -0,0 +1,25 @@
import React, { useState, useEffect } from "react";
const AuthContext = React.createContext();
export function AuthProvider({ children }) {
const [password, setPassword] = useState(
sessionStorage.getItem("auth") || ""
);
useEffect(() => {
sessionStorage.setItem("auth", password);
}, [password]);
const [authenticationStatus, setAuthenticationStatus] = useState("unknown");
const value = {
password,
setPassword,
authenticationStatus,
setAuthenticationStatus,
};
return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>;
}
export default AuthContext;