You've already forked AstralRinth
forked from didirus/AstralRinth
* Start of app redesign * format * continue progress * Content page nearly done * Fix recursion issues with content page * Fix update all alignment * Discover page progress * Settings progress * Removed unlocked-size hack that breaks web * Revamp project page, refactor web project page to share code with app, fixed loading bar, misc UI/UX enhancements, update ko-fi logo, update arrow icons, fix web issues caused by floating-vue migration, fix tooltip issues, update web tooltips, clean up web hydration issues * Ads + run prettier * Begin auth refactor, move common messages to ui lib, add i18n extraction to all apps, begin Library refactor * fix ads not hiding when plus log in * rev lockfile changes/conflicts * Fix sign in page * Add generated * (mostly) Data driven search * Fix search mobile issue * profile fixes * Project versions page, fix typescript on UI lib and misc fixes * Remove unused gallery component * Fix linkfunction err * Search filter controls at top, localization for locked filters * Fix provided filter names * Fix navigating from instance browse to main browse * Friends frontend (#2995) * Friends system frontend * (almost) finish frontend * finish friends, fix lint * Fix lint --------- Signed-off-by: Geometrically <18202329+Geometrically@users.noreply.github.com> * Refresh macOS app icon * Update web search UI more * Fix link opens * Fix frontend build --------- Signed-off-by: Geometrically <18202329+Geometrically@users.noreply.github.com> Co-authored-by: Jai A <jaiagr+gpg@pm.me> Co-authored-by: Geometrically <18202329+Geometrically@users.noreply.github.com>
145 lines
4.1 KiB
Vue
145 lines
4.1 KiB
Vue
<template>
|
|
<div class="universal-card">
|
|
<h2 class="text-2xl">{{ formatMessage(commonSettingsMessages.sessions) }}</h2>
|
|
<p class="preserve-lines">
|
|
{{ formatMessage(messages.sessionsDescription) }}
|
|
</p>
|
|
<div v-for="session in sessions" :key="session.id" class="universal-card recessed session mt-4">
|
|
<div>
|
|
<div>
|
|
<strong>
|
|
{{ session.os ?? formatMessage(messages.unknownOsLabel) }} ⋅
|
|
{{ session.platform ?? formatMessage(messages.unknownPlatformLabel) }} ⋅
|
|
{{ session.ip }}
|
|
</strong>
|
|
</div>
|
|
<div>
|
|
<template v-if="session.city">{{ session.city }}, {{ session.country }} ⋅ </template>
|
|
<span
|
|
v-tooltip="
|
|
formatMessage(commonMessages.dateAtTimeTooltip, {
|
|
date: new Date(session.last_login),
|
|
time: new Date(session.last_login),
|
|
})
|
|
"
|
|
>
|
|
{{
|
|
formatMessage(messages.lastAccessedAgoLabel, {
|
|
ago: formatRelativeTime(session.last_login),
|
|
})
|
|
}}
|
|
</span>
|
|
⋅
|
|
<span
|
|
v-tooltip="
|
|
formatMessage(commonMessages.dateAtTimeTooltip, {
|
|
date: new Date(session.created),
|
|
time: new Date(session.created),
|
|
})
|
|
"
|
|
>
|
|
{{
|
|
formatMessage(messages.createdAgoLabel, {
|
|
ago: formatRelativeTime(session.created),
|
|
})
|
|
}}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
<div class="input-group">
|
|
<i v-if="session.current">{{ formatMessage(messages.currentSessionLabel) }}</i>
|
|
<button v-else class="iconified-button raised-button" @click="revokeSession(session.id)">
|
|
<XIcon /> {{ formatMessage(messages.revokeSessionButton) }}
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
<script setup>
|
|
import { XIcon } from "@modrinth/assets";
|
|
import { commonMessages, commonSettingsMessages } from "@modrinth/ui";
|
|
|
|
definePageMeta({
|
|
middleware: "auth",
|
|
});
|
|
|
|
const { formatMessage } = useVIntl();
|
|
const formatRelativeTime = useRelativeTime();
|
|
|
|
const messages = defineMessages({
|
|
currentSessionLabel: {
|
|
id: "settings.sessions.current-session",
|
|
defaultMessage: "Current session",
|
|
},
|
|
revokeSessionButton: {
|
|
id: "settings.sessions.action.revoke-session",
|
|
defaultMessage: "Revoke session",
|
|
},
|
|
createdAgoLabel: {
|
|
id: "settings.sessions.created-ago",
|
|
defaultMessage: "Created {ago}",
|
|
},
|
|
sessionsDescription: {
|
|
id: "settings.sessions.description",
|
|
defaultMessage:
|
|
"Here are all the devices that are currently logged in with your Modrinth account. You can log out of each one individually.\n\nIf you see an entry you don't recognize, log out of that device and change your Modrinth account password immediately.",
|
|
},
|
|
lastAccessedAgoLabel: {
|
|
id: "settings.sessions.last-accessed-ago",
|
|
defaultMessage: "Last accessed {ago}",
|
|
},
|
|
unknownOsLabel: {
|
|
id: "settings.sessions.unknown-os",
|
|
defaultMessage: "Unknown OS",
|
|
},
|
|
unknownPlatformLabel: {
|
|
id: "settings.sessions.unknown-platform",
|
|
defaultMessage: "Unknown platform",
|
|
},
|
|
});
|
|
|
|
useHead({
|
|
title: () => `${formatMessage(commonSettingsMessages.sessions)} - Modrinth`,
|
|
});
|
|
|
|
const data = useNuxtApp();
|
|
const { data: sessions, refresh } = await useAsyncData("session/list", () =>
|
|
useBaseFetch("session/list"),
|
|
);
|
|
|
|
async function revokeSession(id) {
|
|
startLoading();
|
|
try {
|
|
sessions.value = sessions.value.filter((x) => x.id !== id);
|
|
await useBaseFetch(`session/${id}`, {
|
|
method: "DELETE",
|
|
});
|
|
await refresh();
|
|
} catch (err) {
|
|
data.$notify({
|
|
group: "main",
|
|
title: formatMessage(commonMessages.errorNotificationTitle),
|
|
text: err.data.description,
|
|
type: "error",
|
|
});
|
|
}
|
|
stopLoading();
|
|
}
|
|
</script>
|
|
<style lang="scss" scoped>
|
|
.session {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 0.5rem;
|
|
|
|
@media screen and (min-width: 800px) {
|
|
flex-direction: row;
|
|
align-items: center;
|
|
|
|
.input-group {
|
|
margin-left: auto;
|
|
}
|
|
}
|
|
}
|
|
</style>
|