Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Commit

Permalink
♻️ Allow adding team members without name
Browse files Browse the repository at this point in the history
  • Loading branch information
AnandChowdhary committed Oct 30, 2020
1 parent 8c7f926 commit 63bac41
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/modules/memberships/memberships.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
IsNotEmpty,
IsOptional,
IsString,
MinLength,
} from 'class-validator';

export class UpdateMembershipDto {
Expand All @@ -14,14 +15,15 @@ export class UpdateMembershipDto {
}

export class CreateGroupMembershipDto {
@IsString()
@IsNotEmpty()
name: string;

@IsEmail()
@IsNotEmpty()
email: string;

@IsString()
@IsOptional()
@MinLength(3)
name?: string;

@IsString()
@IsIn(['OWNER', 'ADMIN', 'MEMBER'])
@IsOptional()
Expand Down
2 changes: 1 addition & 1 deletion src/modules/memberships/memberships.interface.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { MembershipRole } from '@prisma/client';

export interface CreateMembershipInput {
name: string;
email: string;
name?: string;
role?: MembershipRole;
}
3 changes: 2 additions & 1 deletion src/modules/memberships/memberships.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ export class MembershipsService {
where: { emails: { some: { emailSafe } } },
}),
);
if (!user) user = await this.auth.register(ipAddress, data);
if (!user)
user = await this.auth.register(ipAddress, { name: data.email, ...data });
const result = await this.prisma.memberships.create({
data: {
role: data.role,
Expand Down

0 comments on commit 63bac41

Please sign in to comment.