fix share password issues
This commit is contained in:
@@ -120,19 +120,24 @@ export async function listShareFiles(
|
||||
| { success: true; files: DirectoryEntry[]; parent: DirectoryEntry | null }
|
||||
| { success: false }
|
||||
> {
|
||||
const { data } = await useFetch<
|
||||
const { data, error } = await useFetch<
|
||||
ApiResponse<{ files: DirectoryEntry[]; parent: DirectoryEntry | null }>
|
||||
>(getApiUrl('warrens/files/ls_share'), {
|
||||
method: 'POST',
|
||||
headers: getApiHeaders(),
|
||||
// This is only required for development
|
||||
headers:
|
||||
password != null
|
||||
? { ...getApiHeaders(), 'X-Share-Password': password }
|
||||
: getApiHeaders(),
|
||||
body: JSON.stringify({
|
||||
shareId: shareId,
|
||||
path: path,
|
||||
password: password,
|
||||
}),
|
||||
});
|
||||
|
||||
if (data.value == null) {
|
||||
const errorMessage = await error.value?.data;
|
||||
console.log(errorMessage);
|
||||
return {
|
||||
success: false,
|
||||
};
|
||||
@@ -174,3 +179,32 @@ export async function fetchShareFile(
|
||||
data: data.value,
|
||||
};
|
||||
}
|
||||
|
||||
export async function verifySharePassword(
|
||||
shareId: string,
|
||||
password: string
|
||||
): Promise<{ success: boolean }> {
|
||||
const { data } = await useFetch<ApiResponse<null>>(
|
||||
getApiUrl(`warrens/files/verify_share_password`),
|
||||
{
|
||||
method: 'POST',
|
||||
headers: getApiHeaders(),
|
||||
body: JSON.stringify({
|
||||
shareId: shareId,
|
||||
password: password,
|
||||
}),
|
||||
responseType: 'json',
|
||||
cache: 'default',
|
||||
}
|
||||
);
|
||||
|
||||
if (data.value == null || data.value.status !== 200) {
|
||||
return {
|
||||
success: false,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user