front end fixes
This commit is contained in:
@@ -12,10 +12,10 @@ export async function GET(event: RequestEvent) {
|
||||
try {
|
||||
const r = await pb.collection('users').listAuthMethods();
|
||||
|
||||
for (const provider of r.authProviders) {
|
||||
for (const provider of r.oauth2.providers) {
|
||||
const imageURL = `${env.PUBLIC_POCKETBASE_URL}/_/images/oauth2/${provider.name}.svg`
|
||||
provider['img' as keyof typeof provider] = await imageUrlToBase64(imageURL, event.fetch);
|
||||
provider['url' as keyof typeof provider] = `${provider.authUrl}${redirectURL}`
|
||||
provider['url' as keyof typeof provider] = `${provider.authURL}${redirectURL}`
|
||||
}
|
||||
return json(r)
|
||||
} catch (e: any) {
|
||||
|
||||
@@ -21,7 +21,7 @@ export async function GET(event: RequestEvent) {
|
||||
parts.push(encodeURIComponent(safeParams.data.record));
|
||||
parts.push(encodeURIComponent(safeParams.data.file));
|
||||
|
||||
let fileURL = pb.buildUrl(parts.join("/"));
|
||||
let fileURL = pb.buildURL(parts.join("/"));
|
||||
|
||||
try {
|
||||
const r = await event.fetch(fileURL)
|
||||
|
||||
@@ -8,7 +8,7 @@ export async function GET(event: RequestEvent) {
|
||||
try {
|
||||
const r = await list<List>(event, Collection.lists);
|
||||
for (const t of r.items) {
|
||||
if (!t.author || !pb.authStore.model) {
|
||||
if (!t.author || !pb.authStore.record) {
|
||||
continue;
|
||||
}
|
||||
if (!t.expand) {
|
||||
|
||||
@@ -9,7 +9,7 @@ export async function GET(event: RequestEvent) {
|
||||
const r = await list<SummitLog>(event, Collection.summit_logs);
|
||||
|
||||
for (const t of r.items) {
|
||||
if (!t.author || !pb.authStore.model) {
|
||||
if (!t.author || !pb.authStore.record) {
|
||||
continue;
|
||||
}
|
||||
if (!t.expand) {
|
||||
|
||||
@@ -9,7 +9,7 @@ export async function GET(event: RequestEvent) {
|
||||
const r = await list<Trail>(event, Collection.trails);
|
||||
|
||||
for (const t of r.items) {
|
||||
if (!t.author || !pb.authStore.model) {
|
||||
if (!t.author || !pb.authStore.record) {
|
||||
continue;
|
||||
}
|
||||
if (!t.expand) {
|
||||
|
||||
@@ -8,7 +8,7 @@ export async function GET(event: RequestEvent) {
|
||||
try {
|
||||
const r = await show<Trail>(event, Collection.trails)
|
||||
|
||||
if (pb.authStore.model) {
|
||||
if (pb.authStore.record) {
|
||||
if (!r.expand) {
|
||||
r.expand = {} as any
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import { handleError } from '$lib/util/api_util';
|
||||
import { error, json, type RequestEvent } from '@sveltejs/kit';
|
||||
|
||||
export async function GET(event: RequestEvent) {
|
||||
if (!pb.authStore.model) {
|
||||
if (!pb.authStore.record) {
|
||||
return json({
|
||||
max_lat: 0,
|
||||
min_lat: 0,
|
||||
@@ -13,7 +13,7 @@ export async function GET(event: RequestEvent) {
|
||||
});
|
||||
}
|
||||
try {
|
||||
const r = await pb.collection('trails_bounding_box').getOne<TrailBoundingBox>(pb.authStore.model!.id)
|
||||
const r = await pb.collection('trails_bounding_box').getOne<TrailBoundingBox>(pb.authStore.record!.id)
|
||||
return json(r)
|
||||
} catch (e: any) {
|
||||
throw handleError(e);
|
||||
|
||||
@@ -4,7 +4,7 @@ import { handleError } from '$lib/util/api_util';
|
||||
import { error, json, type RequestEvent } from '@sveltejs/kit';
|
||||
|
||||
export async function GET(event: RequestEvent) {
|
||||
if (!pb.authStore.model) {
|
||||
if (!pb.authStore.record) {
|
||||
return json({
|
||||
min_distance: 0,
|
||||
max_distance: 20000,
|
||||
@@ -15,7 +15,7 @@ export async function GET(event: RequestEvent) {
|
||||
});
|
||||
}
|
||||
try {
|
||||
const r = await pb.collection('trails_filter').getOne<TrailFilterValues>(pb.authStore.model!.id)
|
||||
const r = await pb.collection('trails_filter').getOne<TrailFilterValues>(pb.authStore.record!.id)
|
||||
return json(r)
|
||||
} catch (e: any) {
|
||||
throw handleError(e);
|
||||
|
||||
@@ -10,7 +10,7 @@ export async function GET(event: RequestEvent) {
|
||||
const searchParams = Object.fromEntries(event.url.searchParams);
|
||||
const safeSearchParams = TrailRecommendSchema.parse(searchParams);
|
||||
|
||||
const r = await event.fetch(pb.buildUrl("/trail/recommend?" + new URLSearchParams({
|
||||
const r = await event.fetch(pb.buildURL("/trail/recommend?" + new URLSearchParams({
|
||||
size: safeSearchParams.size?.toString() ?? ""
|
||||
})));
|
||||
|
||||
@@ -23,7 +23,7 @@ export async function GET(event: RequestEvent) {
|
||||
const result: Trail[] = await r.json();
|
||||
|
||||
for (const t of result) {
|
||||
if (!t.author || !pb.authStore.model) {
|
||||
if (!t.author || !pb.authStore.record) {
|
||||
continue;
|
||||
}
|
||||
if (!t.expand) {
|
||||
|
||||
@@ -23,9 +23,9 @@ export async function POST(event: RequestEvent) {
|
||||
|
||||
const safeData = UserUpdateSchema.parse(data);
|
||||
|
||||
if (safeData.email && safeData.email != pb.authStore.model!.email) {
|
||||
if (safeData.email && safeData.email != pb.authStore.record!.email) {
|
||||
const r = await pb.collection('users').requestEmailChange(safeData.email);
|
||||
pb.authStore.model!.email = safeData.email;
|
||||
pb.authStore.record!.email = safeData.email;
|
||||
}
|
||||
const r = await pb.collection('users').update<User>(safeParams.id, safeData)
|
||||
if (safeData.password) {
|
||||
|
||||
Reference in New Issue
Block a user