diff --git a/src/structures/services/structures.service.ts b/src/structures/services/structures.service.ts index ad300fffffce1c8277578fbb624ff8fda7bc292e..4dd3dfd2746cfbdb6c0fa1af4962d5a110603db6 100644 --- a/src/structures/services/structures.service.ts +++ b/src/structures/services/structures.service.ts @@ -338,7 +338,7 @@ export class StructuresService { public async updateAccountVerified(idStructure: string, emailUser: string): Promise<Structure> { const user = await this.userService.findOne(emailUser); - const structureLinked = await this.findOne(user.structuresLink[0].toHexString()); + const structureLinked = await this.findOne(idStructure); const structure = new this.structureModel(structureLinked); if (!structure) { throw new HttpException('Invalid structure', HttpStatus.NOT_FOUND); diff --git a/src/temp-user/dto/create-temp-user.dto.ts b/src/temp-user/dto/create-temp-user.dto.ts index 892eb6fca9e723f5b3be341d7e3c4cc90cc009de..94b61f14d79a02c1539e8dc775dd9391c0698263 100644 --- a/src/temp-user/dto/create-temp-user.dto.ts +++ b/src/temp-user/dto/create-temp-user.dto.ts @@ -8,14 +8,6 @@ export class CreateTempUserDto { @ApiProperty({ type: String }) email: string; - @IsNotEmpty() - @ApiProperty({ type: String }) - name: string; - - @IsNotEmpty() - @ApiProperty({ type: String }) - surname: string; - @IsArray() @IsOptional() pendingStructuresLink?: Types.ObjectId[]; diff --git a/src/temp-user/temp-user.interface.ts b/src/temp-user/temp-user.interface.ts index b802cf3dd6c66a907bf923f9eaa678c15e7e9d81..1e0a132a1bb71e3fdd88ddc3bd5262e82e0c085e 100644 --- a/src/temp-user/temp-user.interface.ts +++ b/src/temp-user/temp-user.interface.ts @@ -3,7 +3,5 @@ import { Document, Types } from 'mongoose'; export interface ITempUser extends Document { readonly _id: string; email: string; - name: string; - surname: string; pendingStructuresLink: Types.ObjectId[]; } diff --git a/src/temp-user/temp-user.schema.ts b/src/temp-user/temp-user.schema.ts index c8777e3ef81fba888fc2185c754bcdf8d9a435b2..dc70ce2ac22516550162e44b51d4d2523164aa82 100644 --- a/src/temp-user/temp-user.schema.ts +++ b/src/temp-user/temp-user.schema.ts @@ -8,12 +8,6 @@ export class TempUser { @Prop({ required: true }) email: string; - @Prop({ required: true }) - name: string; - - @Prop({ required: true }) - surname: string; - @Prop({ default: null }) pendingStructuresLink: Types.ObjectId[]; } diff --git a/src/users/users.controller.ts b/src/users/users.controller.ts index 2add23768502333ed2facb29b8e65badfe9b0293..5bddaee3d060ef5ee934c92aceeb5495cdc9ce0c 100644 --- a/src/users/users.controller.ts +++ b/src/users/users.controller.ts @@ -8,14 +8,18 @@ import { PasswordResetApplyDto } from './dto/reset-password-apply.dto'; import { PasswordResetDto } from './dto/reset-password.dto'; import { UsersService } from './users.service'; import { StructuresService } from '../structures/services/structures.service'; -import { Types } from 'mongoose'; +import { Mongoose, Types } from 'mongoose'; import { AuthService } from '../auth/auth.service'; import { JwtService } from '@nestjs/jwt'; import { TempUserService } from '../temp-user/temp-user.service'; @Controller('users') export class UsersController { - constructor(private usersService: UsersService, private structureService: StructuresService, private tempUserService: TempUserService) {} + constructor( + private usersService: UsersService, + private structureService: StructuresService, + private tempUserService: TempUserService + ) {} @UseGuards(JwtAuthGuard) @ApiBearerAuth('JWT') @@ -107,9 +111,9 @@ export class UsersController { public async delete(@Req() req) { const user = await this.usersService.deleteOne(req.user.email); user.structuresLink.forEach((structureId) => { - this.usersService.isStructureClaimed(structureId.toHexString()).then((userFound) => { + this.usersService.isStructureClaimed(structureId.toString()).then((userFound) => { if (!userFound) { - this.structureService.deleteOne(structureId.toHexString()); + this.structureService.deleteOne(structureId.toString()); } }); });