Skip to content
Snippets Groups Projects
Commit 4a8723b9 authored by Jérémie BRISON's avatar Jérémie BRISON
Browse files

fix(ownerStructure) : fix return owner object + fix bug hexString()

parent 5a6b4731
No related branches found
No related tags found
3 merge requests!38Recette,!37Dev,!36Fix/add user to structure
......@@ -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);
......
......@@ -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[];
......
......@@ -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[];
}
......@@ -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[];
}
......
......@@ -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());
}
});
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment