Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(web): update unauthorized share link handling #7126

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions web/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
unlinkOAuthAccount,
type UserResponseDto,
} from '@immich/sdk';
import { common } from '@immich/sdk/axios';
import { get } from 'svelte/store';

interface UpdateParamAction {
Expand Down Expand Up @@ -91,7 +90,7 @@ const createUrl = (path: string, parameters?: Record<string, unknown>) => {
const url = new URL(path, 'https://example.com');
url.search = searchParameters.toString();

return defaults.baseUrl + common.toPathString(url);
return defaults.baseUrl + url.pathname + url.search + url.hash;
};

export const getAssetFileUrl = (...[assetId, isWeb, isThumb]: [string, boolean, boolean]) => {
Expand Down
5 changes: 2 additions & 3 deletions web/src/routes/(user)/share/[key]/+page.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { getAssetThumbnailUrl } from '$lib/utils';
import { authenticate } from '$lib/utils/auth';
import { ThumbnailFormat, getMySharedLink } from '@immich/sdk';
import { error as throwError } from '@sveltejs/kit';
import type { AxiosError } from 'axios';
import { error as throwError, type HttpError } from '@sveltejs/kit';
import type { PageLoad } from './$types';

export const load = (async ({ params }) => {
Expand All @@ -25,7 +24,7 @@ export const load = (async ({ params }) => {
} catch (error) {
// handle unauthorized error
// TODO this doesn't allow for 404 shared links anymore
if ((error as AxiosError).response?.status === 401) {
if ((error as HttpError).status === 401) {
return {
passwordRequired: true,
sharedLinkKey: key,
Expand Down