Skip to content

Commit

Permalink
Remove " from oauth tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
starsep committed Jan 17, 2024
1 parent c12e73d commit 8b0d70c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Main.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { osmAuth } from "osm-auth";
import React, { Suspense, useEffect, useMemo, useState } from "react";
import { AppContext } from "~/appContext";
import { fixOsmAuthLocalStorageTokens } from "~/auth";
import CustomModal from "~/components/modal";
import { AuthState } from "~/model/auth";
import { Country } from "~/model/country";
Expand Down Expand Up @@ -34,6 +35,9 @@ function Main() {

const { VITE_OSM_API_URL, VITE_OSM_AUTH_URL, VITE_OSM_OAUTH2_CLIENT_ID } =
import.meta.env;
useEffect(() => {
fixOsmAuthLocalStorageTokens();
}, []);
const redirectPath = window.location.origin + window.location.pathname;
const [auth] = useState(
new osmAuth({
Expand Down
11 changes: 11 additions & 0 deletions src/auth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export function fixOsmAuthLocalStorageTokens() {
for (const key in localStorage) {
if (key.includes("oauth")) {
const oldValue = localStorage.getItem(key);
if (oldValue?.includes('"')) {
const newValue = oldValue.replace(/"/g, "");
localStorage.setItem(key, newValue);
}
}
}
}

0 comments on commit 8b0d70c

Please sign in to comment.