Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API box and font change #51

Merged
merged 4 commits into from
Apr 23, 2024
Merged
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
12 changes: 7 additions & 5 deletions Frontend/src/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import { getCsrfToken } from './utils';
export default function Login({onLoginDataReceived}) {
const [username, setUser] = useState("");
const [password, setPassword] = useState("");
const [apiKey, setApiKey] = useState("")
const [apiKey, setApiKey] = useState("");
const [logState, setLogState] = useState("login");
const [loginResponse, setLoginResponse] = useState("");
const [usingSession, setUsingSession] = useState(true)
const [usingSession, setUsingSession] = useState(true);

useEffect(() => {
let ignore = false
Expand Down Expand Up @@ -54,9 +54,11 @@ export default function Login({onLoginDataReceived}) {
const attemptLogin = async (method) => {
if (method === "login") {
try {
if (localStorage.getItem("canvasAPIKey") == null) {
localStorage.setItem("canvasAPIKey", apiKey);
}
const currentKey = localStorage.getItem("canvasAPIKey");
setApiKey(currentKey);

setLoginResponse(`Logging in user ${username}...`);

await axios.post(`/loginUser`, {
Expand All @@ -76,11 +78,11 @@ export default function Login({onLoginDataReceived}) {
setLoginResponse(`Could not contact CatCorp/Canvas servers!`);
console.log(`Could not contact CatCorp/Canvas servers!`);
}
localStorage.removeItem("canvasAPIKey");
}

} else if (logState === "create") {
setLoginResponse(`Registering user ${username}...`);

try {
await axios.post(`/registerAccount`, {
username: username,
Expand Down Expand Up @@ -140,7 +142,7 @@ export default function Login({onLoginDataReceived}) {
type="password"/>
</div>
{
logState === "create" && <CanvasAPIKeyContainer keyVal={apiKey}
(!localStorage.getItem("canvasAPIKey") || logState === 'create') && <CanvasAPIKeyContainer keyVal={apiKey}
setKey={setApiKey}/>
}
<div className="loginAccount">
Expand Down
2 changes: 1 addition & 1 deletion Frontend/src/css/Login.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ h2 {


.loginContainer {
font-family: 'Courier New', Courier, monospace;
font-family: 'Silkscreen';


position: absolute;
Expand Down
Loading