Skip to content

Commit

Permalink
Merge pull request #121 from seanmorley15/development
Browse files Browse the repository at this point in the history
auth
  • Loading branch information
seanmorley15 authored Jul 12, 2024
2 parents 4d73b9b + b9745cd commit 0494b3f
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions frontend/src/routes/adventures/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,15 +432,28 @@ export const actions: Actions = {
const previous = formData.get('previous') as string;
const page = formData.get('page') as string;

if (!event.locals.user) {
return {
status: 401,
body: { message: 'Unauthorized' }
};
}

if (!page) {
return {
status: 400,
body: { error: 'Missing required fields' }
};
}

// Start with the current URL if next and previous are not provided
let url: string = next || previous || event.url.toString();
// Start with the provided URL or default to the filtered adventures endpoint
let url: string = next || previous || `${serverEndpoint}/api/adventures/filtered`;

// Extract the path and query parameters
const urlParts = url.split('/api');
if (urlParts.length > 1) {
url = `${serverEndpoint}/api${urlParts[1]}`;
}

// Replace or add the page number in the URL
if (url.includes('page=')) {
Expand Down

0 comments on commit 0494b3f

Please sign in to comment.