feat: saveToken plugin for app groups on iOS
This will allow the share extension to access the Bearer token to send images to the backend.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { type Component, type JSX, Show } from "solid-js";
|
||||
import { jwtDecode } from "jwt-decode";
|
||||
import { Navigate } from "@solidjs/router";
|
||||
import { saveToken } from "tauri-plugin-ios-shared-token-api";
|
||||
|
||||
export const isTokenValid = (): boolean => {
|
||||
const token = localStorage.getItem("access");
|
||||
@@ -22,6 +23,15 @@ export const ProtectedRoute: Component<{ children?: JSX.Element }> = (
|
||||
) => {
|
||||
const isValid = isTokenValid();
|
||||
|
||||
if (isValid) {
|
||||
const token = localStorage.getItem("access");
|
||||
if (token == null) {
|
||||
throw new Error("unreachable");
|
||||
}
|
||||
|
||||
saveToken(token);
|
||||
}
|
||||
|
||||
return (
|
||||
<Show when={isValid} fallback={<Navigate href="/login" />}>
|
||||
{props.children}
|
||||
|
||||
Reference in New Issue
Block a user