You've already forked obsidian-visualiser
Migration to Nuxt v4 file structure and dependencies update
This commit is contained in:
77
app/types/auth.d.ts
vendored
Normal file
77
app/types/auth.d.ts
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
import type { ComputedRef, Ref } from 'vue';
|
||||
import type { SessionConfig } from 'h3'
|
||||
|
||||
import 'vue-router';
|
||||
declare module 'vue-router'
|
||||
{
|
||||
interface RouteMeta
|
||||
{
|
||||
requiresAuth?: boolean;
|
||||
guestsGoesTo?: string;
|
||||
usersGoesTo?: string;
|
||||
rights?: string[];
|
||||
validState?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
import '@nuxt/schema';
|
||||
declare module '@nuxt/schema'
|
||||
{
|
||||
interface RuntimeConfig
|
||||
{
|
||||
session: SessionConfig;
|
||||
}
|
||||
}
|
||||
|
||||
export interface UserRawData {
|
||||
id: number;
|
||||
username: string;
|
||||
email: string;
|
||||
state: number;
|
||||
}
|
||||
|
||||
export interface UserExtendedData {
|
||||
signin: Date;
|
||||
lastTimestamp: Date;
|
||||
}
|
||||
|
||||
export type Permissions = { permissions: string[] };
|
||||
|
||||
export type User = UserRawData & UserExtendedData & Permissions;
|
||||
|
||||
export interface UserSession {
|
||||
user?: User;
|
||||
id?: string;
|
||||
}
|
||||
|
||||
export interface UserSessionRequired extends UserSession {
|
||||
user: User;
|
||||
id: string;
|
||||
}
|
||||
|
||||
export interface UserSessionComposable {
|
||||
/**
|
||||
* Computed indicating if the auth session is ready
|
||||
*/
|
||||
ready: ComputedRef<boolean>
|
||||
/**
|
||||
* Computed indicating if the user is logged in.
|
||||
*/
|
||||
loggedIn: ComputedRef<boolean>
|
||||
/**
|
||||
* The user object if logged in, null otherwise.
|
||||
*/
|
||||
user: ComputedRef<User | null>
|
||||
/**
|
||||
* The session object.
|
||||
*/
|
||||
session: Ref<UserSession>
|
||||
/**
|
||||
* Fetch the user session from the server.
|
||||
*/
|
||||
fetch: () => Promise<boolean>
|
||||
/**
|
||||
* Clear the user session and remove the session cookie.
|
||||
*/
|
||||
clear: () => Promise<void>
|
||||
}
|
||||
Reference in New Issue
Block a user