Fix link json again (#12)

Use id token instead of access token
This commit is contained in:
John Wu
2021-02-03 08:35:06 -08:00
committed by GitHub
parent 42870e10c2
commit 98bcab5b81
7 changed files with 8 additions and 8 deletions

View File

@@ -39,7 +39,7 @@ export const FileUploadProvider = ({ children }) => {
const { data } = await uploadFile(file, accessToken, setProgress, cancelUpload);
if (data.message) throw new Error(`${data.error}. ${data.message}`);
const url = ((data && data.link && data.link.link) ? data.link.link : "No URL available");
const url = ((data && data.link) ? data.link : "No URL available");
setLinkURL(url);
setStatus(`Uploaded ${filename}`);
setCancelUpload(null);

View File

@@ -12,7 +12,7 @@ export const UserProvider = ({ children }) => {
if (!localStorage) return;
const token = JSON.parse(localStorage.getItem("token"));
if (!token) return;
const { accessToken: { jwtToken }} = token;
const { idToken: { jwtToken }} = token;
const verifyToken = async (accessToken) => {
const result = await auth.verify(accessToken);
if (result.authenticated) {
@@ -100,7 +100,7 @@ export const UserProvider = ({ children }) => {
const signedIn = (token) => {
setToken(token);
if (!localStorage || !token || !token.accessToken) return;
if (!localStorage || !token || !token.idToken) return;
localStorage.setItem("token", JSON.stringify(token));
}

View File

@@ -4,7 +4,7 @@ import {render, cleanup, screen, fireEvent, waitFor} from "@testing-library/reac
import { UserProvider, useUserContext } from "../Contexts/UserContext";
import auth from "../../services/auth";
const TEST_TOKEN = { accessToken: { jwtToken: "TEST" }};
const TEST_TOKEN = { idToken: { jwtToken: "TEST" }};
describe("UseContext", () => {