feat: Add Apple social login support and allow specifying agent type during social authentication.
This commit is contained in:
@@ -1,4 +1,10 @@
|
||||
import { PartialType, OmitType } from '@nestjs/swagger';
|
||||
import { IsOptional, IsString, Matches } from 'class-validator';
|
||||
import { CreateFieldDto } from './create-field.dto';
|
||||
|
||||
export class UpdateFieldDto extends PartialType(OmitType(CreateFieldDto, ['sectionId'] as const)) {}
|
||||
export class UpdateFieldDto extends PartialType(OmitType(CreateFieldDto, ['sectionId'] as const)) {
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@Matches(/^[a-z0-9_]+$/, { message: 'Slug must contain only lowercase letters, numbers, and underscores' })
|
||||
slug?: string;
|
||||
}
|
||||
|
||||
@@ -134,11 +134,24 @@ export class ProfileFieldsService {
|
||||
|
||||
const data: any = { ...updateFieldDto };
|
||||
|
||||
// If name is being updated, update the slug too
|
||||
if (updateFieldDto.name) {
|
||||
const newSlug = this.generateSlug(updateFieldDto.name);
|
||||
|
||||
// Check if new slug conflicts within the section
|
||||
// If slug is explicitly provided, use it; otherwise auto-generate from name
|
||||
if (updateFieldDto.slug) {
|
||||
const newSlug = updateFieldDto.slug;
|
||||
const existing = await this.prisma.profileField.findFirst({
|
||||
where: {
|
||||
AND: [
|
||||
{ id: { not: id } },
|
||||
{ sectionId: field.sectionId },
|
||||
{ slug: newSlug },
|
||||
],
|
||||
},
|
||||
});
|
||||
if (existing) {
|
||||
throw new ConflictException('A field with this slug already exists in this section');
|
||||
}
|
||||
data.slug = newSlug;
|
||||
} else if (updateFieldDto.name) {
|
||||
const newSlug = this.generateSlug(updateFieldDto.name);
|
||||
const existing = await this.prisma.profileField.findFirst({
|
||||
where: {
|
||||
AND: [
|
||||
@@ -148,11 +161,9 @@ export class ProfileFieldsService {
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
if (existing) {
|
||||
throw new ConflictException('A field with this name already exists in this section');
|
||||
}
|
||||
|
||||
data.slug = newSlug;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user