Improved handling of auth token syncing
This commit is contained in:
@@ -25,6 +25,7 @@ import { isYTBackend } from '$lib/misc';
|
||||
import { isOwnBackend } from '$lib/shared/index';
|
||||
import '$lib/fetchProxy';
|
||||
import { loadContentFilterFromURL } from '$lib/filtering/index.js';
|
||||
import { getKeyValue } from '$lib/api/backend/keyvalue.js';
|
||||
|
||||
export const ssr = false;
|
||||
export const prerender = false;
|
||||
@@ -34,6 +35,13 @@ export async function load({ url }) {
|
||||
await initI18n();
|
||||
}
|
||||
|
||||
if (get(rawMasterKeyStore)) {
|
||||
const authTokenFromCloud = await getKeyValue('authToken');
|
||||
if (typeof authTokenFromCloud === 'string')
|
||||
invidiousAuthStore.set(JSON.parse(authTokenFromCloud));
|
||||
else invidiousAuthStore.set(null);
|
||||
}
|
||||
|
||||
isAndroidTvStore.set((await androidTv.isAndroidTv()).value);
|
||||
|
||||
if (Capacitor.getPlatform() === 'android') {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { resolve } from '$app/paths';
|
||||
import { addOrUpdateKeyValue } from '$lib/api/backend/keyvalue.js';
|
||||
import { invidiousAuthStore } from '$lib/store';
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
|
||||
@@ -7,10 +8,12 @@ export async function load({ url }) {
|
||||
const token = url.searchParams.get('token');
|
||||
|
||||
if (username && token) {
|
||||
invidiousAuthStore.set({
|
||||
const authToken = {
|
||||
username: username,
|
||||
token: token
|
||||
});
|
||||
};
|
||||
invidiousAuthStore.set(authToken);
|
||||
await addOrUpdateKeyValue('authToken', JSON.stringify(authToken));
|
||||
}
|
||||
|
||||
throw redirect(302, resolve('/', {}));
|
||||
|
||||
Reference in New Issue
Block a user