Skip to content

πŸ“š The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.

New sessions interface

Smaug6739850e573fbb93
diff --git a/frontend/app/components/Icon.vue b/frontend/app/components/Icon.vue
index ae33923c..02210e08 100644
--- a/frontend/app/components/Icon.vue
+++ b/frontend/app/components/Icon.vue
@@ -8,7 +8,7 @@
</template>
<script setup lang="ts">
-const props = withDefaults(defineProps<{ name: string; fill?: string; display?: 'sm' | 'md' | 'lg' | 'xl' | 'xxl'; size?: number | string }>(), {
+const props = withDefaults(defineProps<{ name: string; fill?: string; display?: 'xsm' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl'; size?: number | string }>(), {
display: 'md',
fill: 'var(--font-color)',
size: undefined,
@@ -35,6 +35,10 @@ const isUnicode = (str: string) => {
}
/* Custom sizes */
+ &.xsm {
+ width: 15px;
+ height: 15px;
+ }
&.sm {
width: 18px;
height: 18px;
diff --git a/frontend/app/components/OIDCProviders.vue b/frontend/app/components/OIDCProviders.vue
index e8725c22..59b546fe 100644
--- a/frontend/app/components/OIDCProviders.vue
+++ b/frontend/app/components/OIDCProviders.vue
@@ -21,58 +21,7 @@
</template>
<script setup lang="ts">
-// Provider icons as inline SVGs
-const providerIcons: Record<string, { icon: string; color: string; label: string }> = {
- google: {
- icon: `<svg viewBox="0 0 24 24" fill="currentColor"><path d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z" fill="#4285F4"/><path d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z" fill="#34A853"/><path d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z" fill="#FBBC05"/><path d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z" fill="#EA4335"/></svg>`,
- color: '#4285F4',
- label: 'Google',
- },
- discord: {
- icon: `<svg viewBox="0 0 24 24" fill="currentColor"><path d="M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z" fill="#5865F2"/></svg>`,
- color: '#5865F2',
- label: 'Discord',
- },
- github: {
- icon: `<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"/></svg>`,
- color: '#24292e',
- label: 'GitHub',
- },
- microsoft: {
- icon: `<svg viewBox="0 0 24 24" fill="currentColor"><path d="M0 0h11.377v11.372H0zm12.623 0H24v11.372H12.623zM0 12.623h11.377V24H0zm12.623 0H24V24H12.623" fill="#00a4ef"/></svg>`,
- color: '#00a4ef',
- label: 'Microsoft',
- },
- apple: {
- icon: `<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701"/></svg>`,
- color: '#000000',
- label: 'Apple',
- },
- authentik: {
- icon: `<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5" stroke="currentColor" stroke-width="2" fill="none"/></svg>`,
- color: '#fd4b2d',
- label: 'Authentik',
- },
- keycloak: {
- icon: `<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-1 17.93c-3.95-.49-7-3.85-7-7.93 0-.62.08-1.21.21-1.79L9 15v1c0 1.1.9 2 2 2v1.93zm6.9-2.54c-.26-.81-1-1.39-1.9-1.39h-1v-3c0-.55-.45-1-1-1H8v-2h2c.55 0 1-.45 1-1V7h2c1.1 0 2-.9 2-2v-.41c2.93 1.19 5 4.06 5 7.41 0 2.08-.8 3.97-2.1 5.39z" fill="currentColor"/></svg>`,
- color: '#4d4d4d',
- label: 'Keycloak',
- },
- default: {
- icon: `<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12.65 10A5.99 5.99 0 006 6c-3.31 0-6 2.69-6 6s2.69 6 6 6a5.99 5.99 0 006.65-4H17v4h4v-4h3v-4H12.65zM6 14c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z"/></svg>`,
- color: '#6366f1',
- label: 'SSO',
- },
-};
-
-function getProviderConfig(providerName: string) {
- const key = providerName.toLowerCase();
- if (providerIcons[key]) {
- return providerIcons[key];
- }
- return { ...providerIcons.default, label: providerName };
-}
-
+import { getProviderConfig } from '~/helpers/oidc-providers';
const { providers, isEnabled, isLoading, fetchProviders, loginWithProvider } = useOIDC();
onMounted(() => {
diff --git a/frontend/app/components/SessionCard.vue b/frontend/app/components/SessionCard.vue
new file mode 100644
index 00000000..1eed8556
--- /dev/null
+++ b/frontend/app/components/SessionCard.vue
@@ -0,0 +1,291 @@
+<template>
+ <div class="session-card" :class="{ 'current-session': isCurrent, inactive: !session.active }">
+ <div class="session-header">
+ <div class="device-icon" :class="deviceType">
+ <svg v-if="deviceType === 'mobile'" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
+ <rect x="5" y="2" width="14" height="20" rx="2" ry="2" />
+ <line x1="12" y1="18" x2="12" y2="18" />
+ </svg>
+ <Icon v-else name="computer" fill="var(--blue)" />
+ </div>
+ <div class="session-info">
+ <div class="session-title">
+ <span class="browser">{{ parsedUserAgent.browser }}</span>
+ <span class="os">on {{ parsedUserAgent.os }}</span>
+ <span v-if="isCurrent" class="badge current">Current</span>
+ <span v-else-if="!session.active" class="badge inactive">Inactive</span>
+ </div>
+ <div class="session-meta">
+ <span class="meta-item">
+ <Icon name="location" display="xsm" />
+ {{ session.location || 'Unknown location' }}
+ </span>
+ <span class="meta-item">
+ <Icon name="internet" display="xsm" />
+ {{ session.ip_adress || 'Unknown IP' }}
+ </span>
+ </div>
+ </div>
+ </div>
+
+ <div class="session-details">
+ <div class="detail-row">
+ <div class="detail-item">
+ <span class="detail-label">Login</span>
+ <span class="detail-value">{{ formatDate(session.login_timestamp) }}</span>
+ </div>
+ <div class="detail-item">
+ <span class="detail-label">Last activity</span>
+ <span class="detail-value">{{ formatRelativeDateValue(session.last_refresh_timestamp) }}</span>
+ </div>
+ <div v-if="session.logout_timestamp" class="detail-item">
+ <span class="detail-label">Logged out</span>
+ <span class="detail-value">{{ formatDate(session.logout_timestamp) }}</span>
+ </div>
+ </div>
+ </div>
+
+ <div v-if="showUserAgent && session.user_agent" class="session-user-agent">
+ <span class="user-agent-label">User agent</span>
+ <code class="user-agent-value">{{ session.user_agent }}</code>
+ </div>
+ </div>
+</template>
+
+<script setup lang="ts">
+import { parseUserAgent } from '~/helpers/utils';
+
+export interface Session {
+ id: string;
+ user_id: string;
+ expire_token: number;
+ last_refresh_timestamp: number;
+ active: boolean;
+ ip_adress?: string;
+ user_agent?: string;
+ location?: string;
+ type: string;
+ login_timestamp: number;
+ logout_timestamp?: number;
+}
+
+const props = withDefaults(
+ defineProps<{
+ session: Session;
+ isCurrent?: boolean;
+ showUserAgent?: boolean;
+ }>(),
+ {
+ isCurrent: false,
+ showUserAgent: false,
+ },
+);
+
+const { numericDate, formatRelativeDate } = useDateFormatters();
+
+const parsedUserAgent = computed(() => parseUserAgent(props.session.user_agent || ''));
+
+const deviceType = computed(() => {
+ const ua = props.session.user_agent?.toLowerCase() || '';
+ if (ua.includes('mobile') || ua.includes('android') || ua.includes('iphone') || ua.includes('ipad')) {
+ return 'mobile';
+ }
+ return 'desktop';
+});
+
+function formatDate(timestamp: number): string {
+ return numericDate(timestamp);
+}
+
+function formatRelativeDateValue(timestamp: number): string {
+ return formatRelativeDate(timestamp);
+}
+</script>
+
+<style scoped lang="scss">
+.session-card {
+ display: flex;
+ flex-direction: column;
+ gap: 1rem;
+ padding: 1rem 1.25rem;
+ border: 1px solid var(--border-color);
+ border-radius: 12px;
+ background: var(--bg-color);
+ transition: all 0.2s ease;
+
+ &:hover {
+ border-color: var(--border-color-accent);
+ box-shadow: 0 4px 12px rgb(0 0 0 / 6%);
+ }
+
+ &.current-session {
+ border-color: var(--green);
+ background: var(--green-bg-light);
+
+ &:hover {
+ border-color: var(--green);
+ }
+ }
+
+ &.inactive {
+ opacity: 0.7;
+ background: var(--bg-contrast);
+ }
+}
+
+.session-header {
+ display: flex;
+ align-items: flex-start;
+ gap: 1rem;
+}
+
+.device-icon {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: 44px;
+ height: 44px;
+ border-radius: 10px;
+ background: var(--bg-contrast-2);
+ color: var(--font-color);
+ flex-shrink: 0;
+
+ svg {
+ width: 22px;
+ height: 22px;
+ }
+
+ &.mobile {
+ background: var(--purple-bg);
+ color: var(--purple);
+ }
+
+ &.desktop {
+ background: var(--blue-bg);
+ color: var(--blue);
+ }
+}
+
+.session-info {
+ display: flex;
+ flex-direction: column;
+ gap: 0.35rem;
+ flex: 1;
+ min-width: 0;
+}
+
+.session-title {
+ display: flex;
+ align-items: center;
+ flex-wrap: wrap;
+ gap: 0.5rem;
+ font-size: 0.95rem;
+
+ .browser {
+ font-weight: 600;
+ color: var(--font-color-dark);
+ }
+
+ .os {
+ color: var(--font-color-light);
+ }
+}
+
+.badge {
+ display: inline-flex;
+ align-items: center;
+ padding: 0.15rem 0.5rem;
+ border-radius: 20px;
+ font-size: 0.7rem;
+ font-weight: 600;
+ text-transform: uppercase;
+ letter-spacing: 0.03em;
+
+ &.current {
+ background: var(--green-bg);
+ color: var(--green-dark);
+ }
+
+ &.inactive {
+ background: var(--grey-bg);
+ color: var(--grey-dark);
+ }
+}
+
+.session-meta {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 1rem;
+}
+
+.meta-item {
+ display: inline-flex;
+ align-items: center;
+ gap: 0.35rem;
+ font-size: 0.8rem;
+ color: var(--font-color-light);
+
+ svg {
+ width: 14px;
+ height: 14px;
+ opacity: 0.7;
+ }
+}
+
+.session-details {
+ padding-top: 0.75rem;
+ border-top: 1px solid var(--border-color-light);
+}
+
+.detail-row {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 1.5rem;
+}
+
+.detail-item {
+ display: flex;
+ flex-direction: column;
+ gap: 0.2rem;
+}
+
+.detail-label {
+ font-size: 0.7rem;
+ font-weight: 500;
+ text-transform: uppercase;
+ letter-spacing: 0.04em;
+ color: var(--font-color-light);
+}
+
+.detail-value {
+ font-size: 0.85rem;
+ color: var(--font-color);
+}
+
+.session-user-agent {
+ display: flex;
+ flex-direction: column;
+ gap: 0.35rem;
+ padding-top: 0.75rem;
+ border-top: 1px solid var(--border-color-light);
+}
+
+.user-agent-label {
+ font-size: 0.7rem;
+ font-weight: 500;
+ text-transform: uppercase;
+ letter-spacing: 0.04em;
+ color: var(--font-color-light);
+}
+
+.user-agent-value {
+ font-family: var(--monospace-font, 'JetBrains Mono', monospace);
+ font-size: 0.75rem;
+ color: var(--font-color-light);
+ background: var(--bg-contrast);
+ padding: 0.5rem 0.75rem;
+ border-radius: 6px;
+ word-break: break-all;
+ line-height: 1.4;
+}
+</style>
diff --git a/frontend/app/helpers/oidc-providers.ts b/frontend/app/helpers/oidc-providers.ts
new file mode 100644
index 00000000..ce297721
--- /dev/null
+++ b/frontend/app/helpers/oidc-providers.ts
@@ -0,0 +1,59 @@
+const providerIcons: Record<string, { icon: string; label: string; color: string }> = {
+ google: {
+ icon: `<svg viewBox="0 0 24 24" fill="currentColor"><path d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z" fill="#4285F4"/><path d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z" fill="#34A853"/><path d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z" fill="#FBBC05"/><path d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z" fill="#EA4335"/></svg>`,
+ label: 'Google',
+ color: '#4285F4',
+ },
+ discord: {
+ icon: `<svg viewBox="0 0 24 24" fill="currentColor"><path d="M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z" fill="#5865F2"/></svg>`,
+ label: 'Discord',
+ color: '#5865F2',
+ },
+ github: {
+ icon: `<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"/></svg>`,
+ label: 'GitHub',
+ color: '#24292e',
+ },
+ microsoft: {
+ icon: `<svg viewBox="0 0 24 24" fill="currentColor"><path d="M0 0h11.377v11.372H0zm12.623 0H24v11.372H12.623zM0 12.623h11.377V24H0zm12.623 0H24V24H12.623" fill="#00a4ef"/></svg>`,
+ label: 'Microsoft',
+ color: '#00a4ef',
+ },
+ apple: {
+ icon: `<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701"/></svg>`,
+ color: '#000000',
+ label: 'Apple',
+ },
+ authentik: {
+ icon: `<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5" stroke="currentColor" stroke-width="2" fill="none"/></svg>`,
+ color: '#fd4b2d',
+ label: 'Authentik',
+ },
+ keycloak: {
+ icon: `<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-1 17.93c-3.95-.49-7-3.85-7-7.93 0-.62.08-1.21.21-1.79L9 15v1c0 1.1.9 2 2 2v1.93zm6.9-2.54c-.26-.81-1-1.39-1.9-1.39h-1v-3c0-.55-.45-1-1-1H8v-2h2c.55 0 1-.45 1-1V7h2c1.1 0 2-.9 2-2v-.41c2.93 1.19 5 4.06 5 7.41 0 2.08-.8 3.97-2.1 5.39z" fill="currentColor"/></svg>`,
+ color: '#4d4d4d',
+ label: 'Keycloak',
+ },
+ default: {
+ icon: `<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12.65 10A5.99 5.99 0 006 6c-3.31 0-6 2.69-6 6s2.69 6 6 6a5.99 5.99 0 006.65-4H17v4h4v-4h3v-4H12.65zM6 14c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z"/></svg>`,
+ color: '#6366f1',
+ label: 'SSO',
+ },
+};
+
+function getProviderIcon(name: string): string {
+ const key = name.toLowerCase();
+ return providerIcons[key]?.icon ?? providerIcons['default']!.icon;
+}
+
+function getProviderLabel(name: string): string {
+ const key = name.toLowerCase();
+ return providerIcons[key]?.label || name;
+}
+
+function getProviderConfig(name: string) {
+ const key = name.toLowerCase();
+ return providerIcons[key] ?? providerIcons['default']!;
+}
+
+export { getProviderIcon, getProviderLabel, getProviderConfig };
diff --git a/frontend/app/pages/dashboard/settings/_views/security.vue b/frontend/app/pages/dashboard/settings/_views/security.vue
index 4446755e..e7192c95 100644
--- a/frontend/app/pages/dashboard/settings/_views/security.vue
+++ b/frontend/app/pages/dashboard/settings/_views/security.vue
@@ -2,20 +2,19 @@
<div>
<h2 class="app-title">Security</h2>
<p class="app-subtitle">Manage your security settings and monitor your account activity.</p>
- <h3>Last connection</h3>
- <div v-if="store.last_connection" class="last-connection">
- <div style="display: flex">
- <img src="/svg/computer.svg" alt="Device icon" />
- <div>
- <p><strong>Last connection:</strong> {{ numericDate(store.last_connection.timestamp) }}</p>
- <p><strong>IP:</strong> {{ store.last_connection.ip_adress }} ({{ store.last_connection.location }})</p>
- <p><strong>Browser:</strong> {{ parseUserAgent(store.last_connection.user_agent).browser }}</p>
- <p><strong>OS:</strong> {{ parseUserAgent(store.last_connection.user_agent).os }}</p>
- </div>
+ <h3>Active sessions</h3>
+ <p class="section-description">These are the devices that are currently logged into your account.</p>
+ <div class="sessions-list">
+ <SessionCard v-for="(session, index) in store.sessions" :key="session.id" :session="session" :is-current="index === 0" :show-user-agent="true" />
+ </div>
+ <p v-if="store.sessions.length === 0" class="no-sessions">No active sessions found.</p>
+ <div v-if="hasUnrecognizedSession" class="warning-box">
+ <Icon name="warning" display="sm" />
+ <div>
+ <strong>Don't recognize a session?</strong>
+ <p>If you see a session you don't recognize, change your password immediately and click "Log out from all devices" below.</p>
</div>
- <p>{{ store.last_connection.user_agent }}</p>
</div>
- <p class="warning">If you don't recognize this connection, please change your password and click on "Log out from all devices".</p>
<!-- OIDC Linked Accounts -->
<template v-if="oidcEnabled">
@@ -88,17 +87,21 @@
deleting your account.
</p>
</div>
- <AppButton type="danger" @click="openDeleteModal">Delete account</AppButton>
+ <div class="actions-row">
+ <AppButton type="danger" @click="openDeleteModal">Delete account</AppButton>
+ </div>
</div>
</template>
<script setup lang="ts">
+import { getProviderIcon, getProviderLabel } from '~/helpers/oidc-providers';
import DeleteAccountModal from '../_modals/DeleteAccountModal.vue';
-import { parseUserAgent } from '~/helpers/utils';
const emit = defineEmits(['close']);
const store = useUserStore();
+store.fetchSessions();
+
const {
providers: availableProviders,
isEnabled: oidcEnabled,
@@ -109,43 +112,12 @@ const {
isProviderLinked,
} = useOIDC();
-const { numericDate } = useDateFormatters();
-
const loadingOIDC = ref(true);
-// OIDC provider icons (same as in OIDCProviders component)
-const providerIcons: Record<string, { icon: string; label: string }> = {
- google: {
- icon: `<svg viewBox="0 0 24 24" fill="currentColor"><path d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z" fill="#4285F4"/><path d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z" fill="#34A853"/><path d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z" fill="#FBBC05"/><path d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z" fill="#EA4335"/></svg>`,
- label: 'Google',
- },
- discord: {
- icon: `<svg viewBox="0 0 24 24" fill="currentColor"><path d="M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z" fill="#5865F2"/></svg>`,
- label: 'Discord',
- },
- github: {
- icon: `<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"/></svg>`,
- label: 'GitHub',
- },
- microsoft: {
- icon: `<svg viewBox="0 0 24 24" fill="currentColor"><path d="M0 0h11.377v11.372H0zm12.623 0H24v11.372H12.623zM0 12.623h11.377V24H0zm12.623 0H24V24H12.623" fill="#00a4ef"/></svg>`,
- label: 'Microsoft',
- },
- default: {
- icon: `<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12.65 10A5.99 5.99 0 006 6c-3.31 0-6 2.69-6 6s2.69 6 6 6a5.99 5.99 0 006.65-4H17v4h4v-4h3v-4H12.65zM6 14c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z"/></svg>`,
- label: 'SSO',
- },
-};
-
-function getProviderIcon(name: string): string {
- const key = name.toLowerCase();
- return providerIcons[key]?.icon ?? providerIcons['default']!.icon;
-}
-
-function getProviderLabel(name: string): string {
- const key = name.toLowerCase();
- return providerIcons[key]?.label || name;
-}
+// Check if there might be unrecognized sessions (sessions other than current)
+const hasUnrecognizedSession = computed(() => {
+ return store.sessions.length > 1;
+});
function isLinked(providerName: string): boolean {
return isProviderLinked(providerName);
@@ -154,18 +126,17 @@ function isLinked(providerName: string): boolean {
async function linkAccount(providerName: string) {
try {
await linkProvider(providerName);
- // linkProvider handles the redirect automatically
- } catch {
- useNotifications().add({ type: 'error', title: 'Failed to initiate account linking' });
+ } catch (error) {
+ useNotifications().add({ type: 'error', title: (error as Error).message || 'Failed to initiate account linking' });
}
}
async function unlinkAccount(providerName: string) {
- const error = await unlinkProvider(providerName);
- if (!error) {
+ try {
+ await unlinkProvider(providerName);
useNotifications().add({ type: 'success', title: `${getProviderLabel(providerName)} account unlinked` });
- } else {
- useNotifications().add({ type: 'error', title: error.message || 'Failed to unlink account' });
+ } catch (error) {
+ useNotifications().add({ type: 'error', title: (error as Error).message || 'Failed to unlink account' });
}
}
@@ -209,21 +180,55 @@ const openDeleteModal = () => useModal().add(new Modal(shallowRef(DeleteAccountM
</script>
<style scoped lang="scss">
-.last-connection {
- padding: 0.3rem 0.5rem;
+.sessions-list {
+ display: flex;
+ flex-direction: column;
+ gap: 0.75rem;
+ margin-bottom: 1.5rem;
+}
+
+.no-sessions {
+ color: var(--font-color-light);
+ font-style: italic;
+ padding: 1rem;
+ text-align: center;
+ background: var(--bg-contrast);
border-radius: 10px;
- background-color: var(--bg-contrast-2);
- align-items: center;
}
p {
- margin: 0.5rem;
+ margin: 0.5rem 0;
font-size: 0.9rem;
}
-.warning {
- font-size: 0.9rem;
- color: var(--red);
+.warning-box {
+ display: flex;
+ gap: 1rem;
+ padding: 1rem 1.25rem;
+ border-radius: 10px;
+ background: var(--yellow-bg);
+ border: 1px solid var(--yellow-border);
+ margin-bottom: 1.5rem;
+
+ svg {
+ width: 24px;
+ height: 24px;
+ color: var(--yellow);
+ flex-shrink: 0;
+ margin-top: 0.15rem;
+ }
+
+ strong {
+ color: var(--yellow-dark);
+ display: block;
+ margin-bottom: 0.25rem;
+ }
+
+ p {
+ margin: 0;
+ font-size: 0.85rem;
+ color: var(--font-color);
+ }
}
.err {
@@ -303,8 +308,7 @@ p {
}
}
-.no-providers {
- color: var(--text-secondary);
- font-style: italic;
+.actions-row {
+ margin: 0.7rem 0;
}
</style>
diff --git a/frontend/app/stores/db_strustures.d.ts b/frontend/app/stores/db_strustures.d.ts
index bbac2ffb..5b1278bb 100644
--- a/frontend/app/stores/db_strustures.d.ts
+++ b/frontend/app/stores/db_strustures.d.ts
@@ -79,14 +79,19 @@ export interface NodeSearchResult {
updated_timestamp: number;
}
-export interface ConnectionLog {
+export interface Session {
id: string;
user_id: string;
+ //refresh_token: string; // Excluded for security reasons
+ expire_token: number;
+ last_refresh_timestamp: number;
+ active: boolean;
ip_adress?: string;
user_agent?: string;
location?: string;
type: string;
- timestamp: number;
+ login_timestamp: number;
+ logout_timestamp?: number;
}
// Internal structures
diff --git a/frontend/app/stores/user.store.ts b/frontend/app/stores/user.store.ts
index cc2ec3cd..02a4ea51 100644
--- a/frontend/app/stores/user.store.ts
+++ b/frontend/app/stores/user.store.ts
@@ -1,11 +1,11 @@
import { makeRequest } from './_utils';
-import type { User, PublicUser, ConnectionLog } from './db_strustures';
+import type { User, PublicUser, Session } from './db_strustures';
export const useUserStore = defineStore('user', {
state: () => ({
user: undefined as User | undefined,
users: {} as Record<string, PublicUser>,
- last_connection: null as ConnectionLog | null,
+ sessions: [] as Session[],
current_fetching: [] as string[], // List of curently fetching user ids to avoid duplicate requests
}),
getters: {
@@ -35,15 +35,26 @@ export const useUserStore = defineStore('user', {
if (request.status === 'success') return true;
throw request.message;
},
+
async fetch(): Promise<User | undefined> {
if (this.user) return this.user;
- const responce = await makeRequest<{ user: User; last_connection: ConnectionLog }>(`users/@me`, 'GET', {});
+ const responce = await makeRequest<User>(`users/@me`, 'GET', {});
if (responce.status === 'success') {
- if (responce.result) this.user = responce.result.user as User;
- if (responce.result?.last_connection) this.last_connection = responce.result.last_connection as ConnectionLog;
+ if (responce.result) this.user = responce.result as User;
return this.user;
} else throw responce.message;
},
+
+ async fetchSessions(): Promise<Session[]> {
+ if (this.sessions.length) return this.sessions;
+ const response = await makeRequest<Session[]>(`auth/sessions`, 'GET', {});
+ if (response.status === 'success') {
+ this.sessions = response.result as Session[];
+ return this.sessions;
+ }
+ throw response.message;
+ },
+
async fetchPublicUser(id: string): Promise<PublicUser | null> {
if (this.users[id]) return this.users[id];
if (this.current_fetching.includes(id)) return null;
@@ -69,11 +80,13 @@ export const useUserStore = defineStore('user', {
}
throw response.message;
},
+
async fetchById(id: string): Promise<User | undefined> {
const responce = await makeRequest<{ user: User }>(`users/${id}`, 'GET', {});
if (responce.status === 'success') return responce.result?.user as User;
throw responce.message;
},
+
async update(user: User) {
if (!this.user) return;
const request = await makeRequest(`users/${user.id}`, 'PATCH', user);
@@ -82,6 +95,7 @@ export const useUserStore = defineStore('user', {
return this.user;
} else throw request.message;
},
+
async updatePassword(newPassword: string) {
if (!this.user) return;
const request = await makeRequest(`users/${this.user.id}/password`, 'PATCH', { password: newPassword });
@@ -89,16 +103,19 @@ export const useUserStore = defineStore('user', {
return true;
} else throw request.message;
},
+
async requestReset(username: string) {
const request = await makeRequest(`auth/request-reset`, 'POST', { username });
if (request.status === 'success') return true;
throw request.message;
},
+
async resetPassword(token: string, newPassword: string) {
const request = await makeRequest(`auth/reset-password`, 'POST', { token, password: newPassword });
if (request.status === 'success') return true;
throw request.message;
},
+
async logout() {
if (!this.user) return;
const request = await makeRequest(`auth/logout`, 'POST', {});
@@ -106,6 +123,7 @@ export const useUserStore = defineStore('user', {
return true;
} else throw request.message;
},
+
async logout_all() {
if (!this.user) return;
const request = await makeRequest(`auth/logout/all`, 'POST', {});
@@ -113,6 +131,7 @@ export const useUserStore = defineStore('user', {
return true;
} else throw request.message;
},
+
async deleteAccount() {
if (!this.user) return;
const request = await makeRequest(`users/${this.user.id}`, 'DELETE', {});
@@ -121,16 +140,18 @@ export const useUserStore = defineStore('user', {
return true;
} else throw request.message;
},
+
async post_logout() {
this.user = undefined;
useNodesStore().clear();
useUserStore().clear();
if (import.meta.client) localStorage.removeItem('isLoggedIn');
},
+
clear() {
this.user = undefined;
this.users = {};
- this.last_connection = null;
+ this.sessions = [];
this.current_fetching = [];
},
},
diff --git a/frontend/public/app-icons/computer.svg b/frontend/public/app-icons/computer.svg
new file mode 100644
index 00000000..2aa010f6
--- /dev/null
+++ b/frontend/public/app-icons/computer.svg
@@ -0,0 +1 @@
+<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="3" width="20" height="14" rx="2" ry="2" /><line x1="8" y1="21" x2="16" y2="21" /><line x1="12" y1="17" x2="12" y2="21" /></svg>
\ No newline at end of file
diff --git a/frontend/public/app-icons/internet.svg b/frontend/public/app-icons/internet.svg
new file mode 100644
index 00000000..0b255768
--- /dev/null
+++ b/frontend/public/app-icons/internet.svg
@@ -0,0 +1 @@
+<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10" /><line x1="2" y1="12" x2="22" y2="12" /><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z" /></svg>
\ No newline at end of file
diff --git a/frontend/public/app-icons/location.svg b/frontend/public/app-icons/location.svg
new file mode 100644
index 00000000..9c5f2afd
--- /dev/null
+++ b/frontend/public/app-icons/location.svg
@@ -0,0 +1 @@
+<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z" /><circle cx="12" cy="10" r="3" /></svg>
\ No newline at end of file
diff --git a/frontend/public/app-icons/warning.svg b/frontend/public/app-icons/warning.svg
new file mode 100644
index 00000000..c6ae4202
--- /dev/null
+++ b/frontend/public/app-icons/warning.svg
@@ -0,0 +1 @@
+<svg viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"> <path fill-rule="evenodd" d="M8.22 1.754a.25.25 0 00-.44 0L1.698 13.132a.25.25 0 00.22.368h12.164a.25.25 0 00.22-.368L8.22 1.754zm-1.763-.707c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0114.082 15H1.918a1.75 1.75 0 01-1.543-2.575L6.457 1.047zM9 11a1 1 0 11-2 0 1 1 0 012 0zm-.25-5.25a.75.75 0 00-1.5 0v2.5a.75.75 0 001.5 0v-2.5z"> </path> </svg>
\ No newline at end of file