mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Fix linked account being stale after oidc link
This commit is contained in:
parent
95bc5b9f7c
commit
9f42c29714
@ -21,6 +21,7 @@
|
|||||||
import { ZodTypeAny, z } from "zod";
|
import { ZodTypeAny, z } from "zod";
|
||||||
import { Account, AccountP } from "./accounts";
|
import { Account, AccountP } from "./accounts";
|
||||||
import { MMKV } from "react-native-mmkv";
|
import { MMKV } from "react-native-mmkv";
|
||||||
|
import { Platform } from "react-native";
|
||||||
|
|
||||||
export const storage = new MMKV();
|
export const storage = new MMKV();
|
||||||
|
|
||||||
@ -32,6 +33,13 @@ const readAccounts = () => {
|
|||||||
|
|
||||||
const writeAccounts = (accounts: Account[]) => {
|
const writeAccounts = (accounts: Account[]) => {
|
||||||
storage.set("accounts", JSON.stringify(accounts));
|
storage.set("accounts", JSON.stringify(accounts));
|
||||||
|
if (Platform.OS === "web") {
|
||||||
|
const selected = accounts.find((x) => x.selected);
|
||||||
|
if (!selected) return;
|
||||||
|
setCookie("account", selected);
|
||||||
|
// cookie used for images and videos since we can't add Authorization headers in img or video tags.
|
||||||
|
setCookie("X-Bearer", selected?.token.access_token);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const setCookie = (key: string, val?: unknown) => {
|
export const setCookie = (key: string, val?: unknown) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user