another fix
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import { Navigate } from "@solidjs/router";
|
||||
import { platform } from "@tauri-apps/plugin-os";
|
||||
import { jwtDecode } from "jwt-decode";
|
||||
import { Component, ParentProps, Show } from "solid-js";
|
||||
import { Component, createSignal, ParentProps, Show } from "solid-js";
|
||||
import { save_token } from "tauri-plugin-ios-shared-token-api";
|
||||
import { InferOutput, literal, number, object, parse, pipe, string, transform } from "valibot";
|
||||
|
||||
@ -34,6 +34,7 @@ export const getTokenProperties = (token: string): InferOutput<typeof accessToke
|
||||
|
||||
export const ProtectedRoute: Component<ParentProps> = (props) => {
|
||||
const isValid = isTokenValid();
|
||||
const [error, setError] = createSignal<string | undefined>();
|
||||
|
||||
if (isValid) {
|
||||
const token = localStorage.getItem("refresh");
|
||||
@ -47,12 +48,15 @@ export const ProtectedRoute: Component<ParentProps> = (props) => {
|
||||
// This involves App Groups.
|
||||
save_token(token)
|
||||
.then(() => console.log("Saved token!!!"))
|
||||
.catch((e) => console.error(e));
|
||||
.catch((e) => setError("Couldnt save token: " + e));
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Show when={isValid} fallback={<Navigate href="/login" />}>
|
||||
<Show when={error()}>
|
||||
{e => <h2 class="text-2xl font-bold">{e()}</h2>}
|
||||
</Show>
|
||||
{props.children}
|
||||
</Show>
|
||||
);
|
||||
|
Reference in New Issue
Block a user