UNPKG

nuxt-users

Version:

A comprehensive user management module for Nuxt 3 and Nuxt 4 applications with authentication, authorization, database support, and CLI tools

65 lines (64 loc) 2.71 kB
import type { ModuleOptions, User, UserWithoutPassword } from '../../../types.js'; interface CreateUserParams { email: string; name: string; password: string; role?: string; } /** * Creates a new user in the database. * Hashes the password before storing. */ export declare const createUser: (userData: CreateUserParams, options: ModuleOptions) => Promise<Omit<User, "password">>; /** * Finds a user by their email address. */ export declare const findUserByEmail: (email: string, options: ModuleOptions) => Promise<User | null>; /** * Finds a user by their ID. */ export declare const findUserById: <T extends boolean = false>(id: number, options: ModuleOptions, withPass?: T) => Promise<T extends true ? User | null : UserWithoutPassword | null>; /** * Updates a user's details. */ export declare const updateUser: (id: number, userData: Partial<User>, options: ModuleOptions) => Promise<UserWithoutPassword>; /** * Deletes a user by their ID. */ export declare const deleteUser: (id: number, options: ModuleOptions) => Promise<void>; /** * Updates a user's password. * Hashes the new password before storing. */ export declare const updateUserPassword: (email: string, newPassword: string, options: ModuleOptions) => Promise<void>; export declare const hasAnyUsers: (options: ModuleOptions) => Promise<boolean>; /** * Gets the current user from an authentication token. */ export declare const getCurrentUserFromToken: <T extends boolean = false>(token: string, options: ModuleOptions, withPass?: T) => Promise<T extends true ? User | null : UserWithoutPassword | null>; /** * Deletes expired personal access tokens from the database. */ export declare const deleteExpiredPersonalAccessTokens: (options: ModuleOptions) => Promise<number>; /** * Deletes tokens without expiration dates (legacy tokens or security cleanup). */ export declare const deleteTokensWithoutExpiration: (options: ModuleOptions) => Promise<number>; /** * Comprehensive token cleanup: removes expired tokens and optionally tokens without expiration. */ export declare const cleanupPersonalAccessTokens: (options: ModuleOptions, includeNoExpiration?: boolean) => Promise<{ expiredCount: number; noExpirationCount: number; totalCount: number; }>; /** * Revokes all tokens for a specific user. */ export declare const revokeUserTokens: (userId: number, options: ModuleOptions) => Promise<void>; /** * Gets the last login time for a user based on their most recent personal access token creation. * This represents when the user last successfully logged in. */ export declare const getLastLoginTime: (userId: number, options: ModuleOptions) => Promise<string | null>; export {};