feat: add SSO workspace, named shares and Debian release tooling
This commit is contained in:
1 parent
833d908884
commit
87bc33e675
106 files changed
+4160
-5637
No files matched your search
@@ -1,4 +1,3 @@
|
||||
import { useAuthStore } from "@/stores/auth";
|
||||
import { useLayoutStore } from "@/stores/layout";
|
||||
import { baseURL } from "@/utils/constants";
|
||||
import { upload as postTus, useTus } from "./tus";
|
||||
@@ -139,7 +138,6 @@ async function postResources(
|
||||
bufferContent = await new Response(content).arrayBuffer();
|
||||
}
|
||||
|
||||
const authStore = useAuthStore();
|
||||
return new Promise((resolve, reject) => {
|
||||
const request = new XMLHttpRequest();
|
||||
request.open(
|
||||
@@ -147,7 +145,7 @@ async function postResources(
|
||||
`${baseURL}/api/resources${url}?override=${overwrite}`,
|
||||
true
|
||||
);
|
||||
request.setRequestHeader("X-Auth", authStore.jwt);
|
||||
request.setRequestHeader("X-FB-Request", "1");
|
||||
|
||||
if (typeof onupload === "function") {
|
||||
request.upload.onprogress = onupload;
|
||||
|
||||
@@ -19,7 +19,8 @@ export async function create(
|
||||
url: string,
|
||||
password = "",
|
||||
expires = "",
|
||||
unit = "hours"
|
||||
unit = "hours",
|
||||
key = ""
|
||||
) {
|
||||
url = removePrefix(url);
|
||||
url = `/api/share${url}`;
|
||||
@@ -27,8 +28,9 @@ export async function create(
|
||||
url += `?expires=${expires}&unit=${unit}`;
|
||||
}
|
||||
let body = "{}";
|
||||
if (password != "" || expires !== "" || unit !== "hours") {
|
||||
if (password != "" || expires !== "" || unit !== "hours" || key !== "") {
|
||||
body = JSON.stringify({
|
||||
key,
|
||||
password: password,
|
||||
expires: expires.toString(), // backend expects string not number
|
||||
unit: unit,
|
||||
@@ -41,5 +43,5 @@ export async function create(
|
||||
}
|
||||
|
||||
export function getShareURL(share: Share) {
|
||||
return createURL("share/" + share.hash, {});
|
||||
return createURL("s/" + share.hash, {});
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
import * as tus from "tus-js-client";
|
||||
import { baseURL, tusEndpoint, tusSettings, origin } from "@/utils/constants";
|
||||
import { useAuthStore } from "@/stores/auth";
|
||||
import { removePrefix } from "@/api/utils";
|
||||
|
||||
const RETRY_BASE_DELAY = 1000;
|
||||
@@ -21,8 +20,6 @@ export async function upload(
|
||||
filePath = removePrefix(filePath);
|
||||
const resourcePath = `${tusEndpoint}${filePath}?override=${overwrite}`;
|
||||
|
||||
const authStore = useAuthStore();
|
||||
|
||||
// Exit early because of typescript, tus content can't be a string
|
||||
if (content === "") {
|
||||
return false;
|
||||
@@ -35,7 +32,7 @@ export async function upload(
|
||||
parallelUploads: 1,
|
||||
storeFingerprintForResuming: false,
|
||||
headers: {
|
||||
"X-Auth": authStore.jwt,
|
||||
"X-FB-Request": "1",
|
||||
},
|
||||
onShouldRetry: function (err) {
|
||||
const status = err.originalResponse
|
||||
@@ -43,7 +40,7 @@ export async function upload(
|
||||
: 0;
|
||||
|
||||
// Do not retry for file conflict.
|
||||
if (status === 409) {
|
||||
if (status === 409 || status === 401 || status === 403) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useAuthStore } from "@/stores/auth";
|
||||
import { renew, logout } from "@/utils/auth";
|
||||
import { startLogin } from "@/utils/auth";
|
||||
import { baseURL } from "@/utils/constants";
|
||||
import { encodePath } from "@/utils/url";
|
||||
|
||||
@@ -29,7 +29,7 @@ export async function fetchURL(
|
||||
try {
|
||||
res = await fetch(`${baseURL}${url}`, {
|
||||
headers: {
|
||||
"X-Auth": authStore.jwt,
|
||||
"X-FB-Request": "1",
|
||||
...headers,
|
||||
},
|
||||
...rest,
|
||||
@@ -42,10 +42,6 @@ export async function fetchURL(
|
||||
throw new StatusError("000 No connection", 0);
|
||||
}
|
||||
|
||||
if (auth && res.headers.get("X-Renew-Token") === "true") {
|
||||
await renew(authStore.jwt);
|
||||
}
|
||||
|
||||
if (res.status < 200 || res.status > 299) {
|
||||
const body = await res.text();
|
||||
const error = new StatusError(
|
||||
@@ -54,7 +50,8 @@ export async function fetchURL(
|
||||
);
|
||||
|
||||
if (auth && res.status == 401) {
|
||||
logout();
|
||||
authStore.clearUser();
|
||||
startLogin();
|
||||
}
|
||||
|
||||
throw error;
|
||||
|
||||
Reference in new issue
Block a user