feat: enhance authentication and user management with token-based system
- Implemented robust token-based authentication with access and refresh tokens - Added JWT token generation, verification, and rotation mechanisms - Created services for token management, Memcached, and MinIO storage - Enhanced user registration and login with device-specific tokens - Added support for profile picture upload and management via MinIO - Implemented secure password hashing with crypto - Updated Prisma schema to support refresh tokens and profile picture storage - Added GraphQL mutations for logout, token refresh, and profile picture handling - Integrated environment configuration with Zod validation - Improved error handling and authentication middleware
This commit is contained in:
parent
d4d99fb5e7
commit
d29d116214
22 changed files with 1992 additions and 388 deletions
18
apps/api/src/utils/middlewares.ts
Normal file
18
apps/api/src/utils/middlewares.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
import { MercuriusContext } from 'mercurius';
|
||||
|
||||
const isCallback = (
|
||||
maybeFunction: unknown | Function
|
||||
): maybeFunction is Function => typeof maybeFunction === 'function';
|
||||
|
||||
export const withAuth = <T>(callback: T) =>
|
||||
async function (
|
||||
_: unknown,
|
||||
__: unknown,
|
||||
context: MercuriusContext,
|
||||
info: unknown
|
||||
) {
|
||||
if (!context.jwt) {
|
||||
throw new Error('Not authenticated!');
|
||||
}
|
||||
return isCallback(callback) && callback(_, __, context, info);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue