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:
2025-05-01 18:20:26 +01:00
parent c8d9ae7aff
commit 61e9258538
32 changed files with 857 additions and 1 deletions

View File

@@ -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}