tempfix: possibly fix site not returning user info
This commit is contained in:
1 parent
f420ced79c
commit
95f67437ec
2 files changed
+5
-13
No files matched your search
+3
-12
@@ -123,8 +123,9 @@ export let profile: Readable<Profile> = derived(
|
|||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (!res?.user)
|
if (!res?.user)
|
||||||
toast({
|
toast({
|
||||||
content: 'Your login has expired. Re-login to fix this issue.',
|
content:
|
||||||
type: 'warning',
|
"Your account's instance did not return your user data. Your login may have expired.",
|
||||||
|
type: 'error',
|
||||||
})
|
})
|
||||||
|
|
||||||
site.set(res?.site)
|
site.set(res?.site)
|
||||||
@@ -324,16 +325,6 @@ function serializeUser(user: Profile): Profile {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
instance.subscribe(async (i) => {
|
|
||||||
try {
|
|
||||||
// fetching site is handled by auth.ts if logged in
|
|
||||||
if (get(profile)?.jwt) return
|
|
||||||
const s = await new LemmyHttp(`https://${i}`).getSite()
|
|
||||||
|
|
||||||
site.set(s)
|
|
||||||
} catch (e) {}
|
|
||||||
})
|
|
||||||
|
|
||||||
export async function setUserID(id: number) {
|
export async function setUserID(id: number) {
|
||||||
profileData.update((p) => ({ ...p, profile: id }))
|
profileData.update((p) => ({ ...p, profile: id }))
|
||||||
return get(profile)
|
return get(profile)
|
||||||
|
|||||||
+2
-1
@@ -65,10 +65,11 @@ export function client({
|
|||||||
|
|
||||||
let jwt = auth ? auth : get(profile)?.jwt
|
let jwt = auth ? auth : get(profile)?.jwt
|
||||||
|
|
||||||
let headers = jwt ? { Authorization: `Bearer ${jwt}` } : { Authorization: '' }
|
let headers = jwt ? { Authorization: `Bearer ${jwt}` } : {}
|
||||||
|
|
||||||
return new LemmyHttp(instanceToURL(instanceURL), {
|
return new LemmyHttp(instanceToURL(instanceURL), {
|
||||||
fetchFunction: (input, init) => customFetch(func, input, init, jwt),
|
fetchFunction: (input, init) => customFetch(func, input, init, jwt),
|
||||||
|
//@ts-ignore
|
||||||
headers: headers,
|
headers: headers,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user