Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions frontend/src/utils/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
logoutPage,
authLogoutURL,
} from "./constants";
import { StatusError } from "@/api/utils";
import { fetchURL, StatusError } from "@/api/utils";
import { setSafeTimeout } from "@/api/utils";

export function parseToken(token: string) {
Expand Down Expand Up @@ -122,20 +122,15 @@ export async function signup(username: string, password: string) {
}

export function logout(reason?: string) {
document.cookie = "auth=; Max-Age=0; Path=/; SameSite=Strict;";

if (authMethod === "proxy" && authLogoutURL !== "") {
// Hostinger specific
fetch(authLogoutURL, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
}).catch(() => {
fetchURL(authLogoutURL, { method: "POST" }).catch(() => {
console.error("Failed to logout using proxy auth");
});
}

document.cookie = "auth=; Max-Age=0; Path=/; SameSite=Strict;";

const authStore = useAuthStore();
authStore.clearUser();

Expand Down
28 changes: 27 additions & 1 deletion frontend/src/views/files/FileListing.vue
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,13 @@
:label="t('buttons.share')"
show="share"
/>
<action
v-if="editAvailable"
id="edit-button"
icon="mode_edit"
:label="t('buttons.edit')"
@action="openSelectedFile"
/>
<action
v-if="headerButtons.rename"
icon="mode_edit"
Expand Down Expand Up @@ -413,7 +420,7 @@ import {
toRef,
watch,
} from "vue";
import { useRoute, onBeforeRouteUpdate } from "vue-router";
import { useRoute, useRouter, onBeforeRouteUpdate } from "vue-router";
import { useI18n } from "vue-i18n";
import { removePrefix } from "@/api/utils";

Expand All @@ -438,6 +445,7 @@ const route = useRoute();
onBeforeRouteUpdate(() => {
hideContextMenu();
});
const router = useRouter();

const { t } = useI18n();

Expand Down Expand Up @@ -1162,6 +1170,24 @@ const handleEmptyAreaClick = (e: MouseEvent) => {

fileStore.selected = [];
};

const editAvailable = computed((): boolean => {
return (
fileStore.selectedCount === 1 &&
fileStore.req !== null &&
!fileStore.req.items[fileStore.selected[0]].isDir
);
});

const openSelectedFile = () => {
if (
fileStore.selectedCount === 1 &&
fileStore.req !== null &&
!fileStore.req.items[fileStore.selected[0]].isDir
) {
router.push({ path: fileStore.req.items[fileStore.selected[0]].url });
}
};
</script>
<style scoped>
#listing {
Expand Down