namespacing

This commit is contained in:
mrjvs
2023-10-29 15:39:46 +01:00
parent e9f8845506
commit 1f85631f55
3 changed files with 8 additions and 1 deletions

View File

@@ -27,7 +27,7 @@ Backend for movie-web
- [ ] ratelimits (stored in redis)
- [X] switch to pnpm
- [X] catpcha support
- [ ] global namespacing (accounts are stored on a namespace)
- [X] global namespacing (accounts are stored on a namespace)
- [ ] cleanup jobs
- [ ] cleanup expired sessions
- [ ] cleanup old metrics

View File

@@ -12,6 +12,9 @@ export class User {
@PrimaryKey({ name: 'id', type: 'uuid' })
id: string = randomUUID();
@Property({ name: 'namespace' })
namespace!: string;
@Property({ type: 'date' })
createdAt: Date = new Date();
@@ -30,6 +33,7 @@ export class User {
export interface UserDTO {
id: string;
namespace: string;
name: string;
roles: string[];
createdAt: string;
@@ -43,6 +47,7 @@ export interface UserDTO {
export function formatUser(user: User): UserDTO {
return {
id: user.id,
namespace: user.namespace,
name: user.name,
roles: user.roles,
createdAt: user.createdAt.toISOString(),

View File

@@ -7,6 +7,7 @@ import { makeSession, makeSessionToken } from '@/services/session';
import { z } from 'zod';
const registerSchema = z.object({
namespace: z.string().min(1),
name: z.string().max(500).min(1),
device: z.string().max(500).min(1),
profile: z.object({
@@ -25,6 +26,7 @@ export const manageAuthRouter = makeRouter((app) => {
await assertCaptcha(body.captchaToken);
const user = new User();
user.namespace = body.namespace;
user.name = body.name;
user.profile = body.profile;