Skip to content

Commit

Permalink
frontend: rename localStorage key secret_key to secretKey to be more …
Browse files Browse the repository at this point in the history
…consistent.
  • Loading branch information
ffreddow committed Oct 15, 2024
1 parent 9b141e6 commit 3819e0e
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 9 deletions.
2 changes: 1 addition & 1 deletion frontend/src/components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export async function logout(logout_all: boolean) {
});

localStorage.removeItem("loginKey");
localStorage.removeItem("secret_key");
localStorage.removeItem("secretKey");

window.location.reload();
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/charger_list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export class ChargerListComponent extends Component<{}, ChargerListComponentStat
showAlert(t("alert_default_text"), "danger");
return;
}
const encoded_key = localStorage.getItem("secret_key");
const encoded_key = localStorage.getItem("secretKey");
const secret_key = Base64.toUint8Array(encoded_key);
const secret_data = await get_secret_resp.json();
secret = sodium.crypto_secretbox_open_easy(new Uint8Array(secret_data.secret), new Uint8Array(secret_data.secret_nonce), secret_key);
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class Login extends Component<{}, LoginState> {
const secret_key = await generate_hash(this.state.password, new Uint8Array(secret_salt), sodium.crypto_secretbox_KEYBYTES);
const encoded_key = Base64.fromUint8Array(secret_key);

localStorage.setItem("secret_key", encoded_key);
localStorage.setItem("secretKey", encoded_key);
window.location.reload()
}

Expand Down
7 changes: 1 addition & 6 deletions frontend/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ async function refresh_access_token() {
});

if (resp.status == 200) {
if (!localStorage.getItem("loginKey") || !localStorage.getItem("secret_key")) {
if (!localStorage.getItem("loginKey") || !localStorage.getItem("secretKey")) {
logout(false);
return;
}
loggedIn.value = AppState.LoggedIn;
} else {
Expand All @@ -72,10 +71,6 @@ setInterval(async () => {
export function App() {
const {t} = useTranslation("", {useSuspense: false});

if (!localStorage.getItem("secret_key") && loggedIn.value == AppState.LoggedIn) {
logout(false);
}

switch (loggedIn.value) {
case AppState.Loading:
return <>
Expand Down

0 comments on commit 3819e0e

Please sign in to comment.