1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2024-12-23 01:27:14 +02:00

fixing User middleware

This commit is contained in:
Patrik J. Braun 2022-03-30 22:27:41 +02:00
parent a2e576ec27
commit 0c2099fa5e
3 changed files with 5 additions and 4 deletions

2
package-lock.json generated
View File

@ -125,7 +125,7 @@
"zone.js": "0.11.5"
},
"engines": {
"node": ">=14.14 <16.0"
"node": ">=16 <17.0"
},
"optionalDependencies": {
"ffmpeg-static": "5.0.0",

View File

@ -1,4 +1,5 @@
import {NextFunction, Request, Response} from 'express';
import { MoreThanOrEqual } from 'typeorm';
import {ErrorCodes, ErrorDTO} from '../../../common/entities/Error';
import {UserRoles} from '../../../common/entities/UserDTO';
import {ObjectManagers} from '../../model/ObjectManagers';
@ -40,7 +41,7 @@ export class UserRequestConstrainsMWs {
// TODO: fix it!
try {
const result = await ObjectManagers.getInstance().UserManager.find({minRole: UserRoles.Admin});
const result = await ObjectManagers.getInstance().UserManager.find({role: MoreThanOrEqual(UserRoles.Admin)});
if (result.length <= 1) {
return next(new ErrorDTO(ErrorCodes.GENERAL_ERROR));
}

View File

@ -25,9 +25,9 @@ export class UserManager implements IUserManager {
}
public async find(filter: any): Promise<any> {
public async find(filter: FindOptionsWhere<UserDTO>): Promise<any> {
const connection = await SQLConnection.getConnection();
return await connection.getRepository(UserEntity).find(filter);
return await connection.getRepository(UserEntity).findBy(filter);
}
public async createUser(user: UserDTO): Promise<any> {