mirror of
https://github.com/immich-app/immich
synced 2026-08-15 13:03:57 +00:00
Merge 7fdbcb0878 into af33a78d18
This commit is contained in:
commit
aad7fa0402
6 changed files with 24 additions and 12 deletions
|
|
@ -22,7 +22,7 @@ import { UserMetadataItem } from 'src/types';
|
|||
export type AuthUser = {
|
||||
id: string;
|
||||
isAdmin: boolean;
|
||||
name: string;
|
||||
name: string | null;
|
||||
email: string;
|
||||
quotaUsageInBytes: number;
|
||||
quotaSizeInBytes: number | null;
|
||||
|
|
@ -125,7 +125,7 @@ export type Asset = {
|
|||
|
||||
export type User = {
|
||||
id: string;
|
||||
name: string;
|
||||
name: string | null;
|
||||
email: string;
|
||||
avatarColor: UserAvatarColor | null;
|
||||
profileImagePath: string;
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ const LoginResponseSchema = z
|
|||
accessToken: z.string().describe('Access token'),
|
||||
userId: z.uuidv4().describe('User ID'),
|
||||
userEmail: toEmail.describe('User email'),
|
||||
name: z.string().describe('User name'),
|
||||
name: z.string().nullable().describe('User name'),
|
||||
profileImagePath: z.string().describe('Profile image path'),
|
||||
isAdmin: z.boolean().describe('Is admin user'),
|
||||
shouldChangePassword: z.boolean().describe('Should change password'),
|
||||
|
|
@ -64,7 +64,7 @@ const LogoutResponseSchema = z
|
|||
.meta({ id: 'LogoutResponseDto' });
|
||||
|
||||
const SignUpSchema = LoginCredentialSchema.extend({
|
||||
name: z.string().describe('User name').meta({ example: 'Admin' }),
|
||||
name: z.string().transform(v => v === '' ? null : v).describe('User name').meta({ example: 'Admin' }),
|
||||
}).meta({ id: 'SignUpDto' });
|
||||
|
||||
const ChangePasswordSchema = z
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import z from 'zod';
|
|||
const SyncUserV1Schema = z
|
||||
.object({
|
||||
id: z.uuidv4().describe('User ID'),
|
||||
name: z.string().describe('User name'),
|
||||
name: z.string().nullable().describe('User name'),
|
||||
email: z.string().describe('User email'),
|
||||
avatarColor: UserAvatarColorSchema.nullish(),
|
||||
deletedAt: isoDatetimeToDate.nullable().describe('User deleted at'),
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ export const UserUpdateMeSchema = z
|
|||
.optional()
|
||||
.describe('User password (deprecated, use change password endpoint)')
|
||||
.meta({ deprecated: true }),
|
||||
name: z.string().optional().describe('User name'),
|
||||
name: z.string().nullish().transform(v => v === '' ? null : v),
|
||||
avatarColor: UserAvatarColorSchema.nullish(),
|
||||
})
|
||||
.meta({ id: 'UserUpdateMeDto' });
|
||||
|
|
@ -25,7 +25,7 @@ export class UserUpdateMeDto extends createZodDto(UserUpdateMeSchema) {}
|
|||
export const UserResponseSchema = z
|
||||
.object({
|
||||
id: z.uuidv4().describe('User ID'),
|
||||
name: z.string().describe('User name'),
|
||||
name: z.string().nullable().describe('User name'),
|
||||
email: toEmail.describe('User email'),
|
||||
profileImagePath: z.string().describe('Profile image path'),
|
||||
avatarColor: UserAvatarColorSchema,
|
||||
|
|
@ -78,7 +78,7 @@ export const UserAdminCreateSchema = z
|
|||
.object({
|
||||
email: toEmail.describe('User email'),
|
||||
password: z.string().describe('User password'),
|
||||
name: z.string().describe('User name'),
|
||||
name: z.string().transform(v => v === '' ? null : v).describe('User name'),
|
||||
avatarColor: UserAvatarColorSchema.nullish(),
|
||||
pinCode: z.string().regex(pinCodeRegex).nullable().optional().describe('PIN code').meta({ example: '123456' }),
|
||||
storageLabel: z.string().pipe(sanitizeFilename).nullish().describe('Storage label'),
|
||||
|
|
@ -96,7 +96,7 @@ const UserAdminUpdateSchema = z
|
|||
email: toEmail.optional().describe('User email'),
|
||||
password: z.string().optional().describe('User password'),
|
||||
pinCode: z.string().regex(pinCodeRegex).nullable().optional().describe('PIN code').meta({ example: '123456' }),
|
||||
name: z.string().optional().describe('User name'),
|
||||
name: z.string().nullish().transform(v => v === '' ? null : v),
|
||||
avatarColor: UserAvatarColorSchema.nullish(),
|
||||
storageLabel: z.string().pipe(sanitizeFilename).nullish().describe('Storage label'),
|
||||
shouldChangePassword: z.boolean().optional().describe('Require password change on next login'),
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
import { Kysely, sql } from 'kysely';
|
||||
|
||||
export async function up(db: Kysely<any>): Promise<void> {
|
||||
await sql`ALTER TABLE "user" ALTER COLUMN "name" DROP NOT NULL;`.execute(db);
|
||||
await sql`ALTER TABLE "user" ALTER COLUMN "name" SET DEFAULT NULL;`.execute(db);
|
||||
await sql`UPDATE "user" SET "name" = NULL WHERE "name" = '';`.execute(db);
|
||||
}
|
||||
|
||||
export async function down(db: Kysely<any>): Promise<void> {
|
||||
await sql`UPDATE "user" SET "name" = '' WHERE "name" IS NULL;`.execute(db);
|
||||
await sql`ALTER TABLE "user" ALTER COLUMN "name" SET DEFAULT '';`.execute(db);
|
||||
await sql`ALTER TABLE "user" ALTER COLUMN "name" SET NOT NULL;`.execute(db);
|
||||
}
|
||||
|
|
@ -64,9 +64,8 @@ export class UserTable {
|
|||
@Column({ unique: true, nullable: true, default: null })
|
||||
storageLabel!: string | null;
|
||||
|
||||
// TODO remove default, make nullable, and convert empty spaces to null
|
||||
@Column({ default: '' })
|
||||
name!: string;
|
||||
@Column({ nullable: true, default: null })
|
||||
name!: string | null;
|
||||
|
||||
@Column({ type: 'bigint', nullable: true })
|
||||
quotaSizeInBytes!: ColumnType<number> | null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue