mirror of
https://github.com/bpatrik/pigallery2.git
synced 2025-01-10 04:07:35 +02:00
fixing User middleware
This commit is contained in:
parent
a2e576ec27
commit
0c2099fa5e
2
package-lock.json
generated
2
package-lock.json
generated
@ -125,7 +125,7 @@
|
|||||||
"zone.js": "0.11.5"
|
"zone.js": "0.11.5"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=14.14 <16.0"
|
"node": ">=16 <17.0"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"ffmpeg-static": "5.0.0",
|
"ffmpeg-static": "5.0.0",
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import {NextFunction, Request, Response} from 'express';
|
import {NextFunction, Request, Response} from 'express';
|
||||||
|
import { MoreThanOrEqual } from 'typeorm';
|
||||||
import {ErrorCodes, ErrorDTO} from '../../../common/entities/Error';
|
import {ErrorCodes, ErrorDTO} from '../../../common/entities/Error';
|
||||||
import {UserRoles} from '../../../common/entities/UserDTO';
|
import {UserRoles} from '../../../common/entities/UserDTO';
|
||||||
import {ObjectManagers} from '../../model/ObjectManagers';
|
import {ObjectManagers} from '../../model/ObjectManagers';
|
||||||
@ -40,7 +41,7 @@ export class UserRequestConstrainsMWs {
|
|||||||
|
|
||||||
// TODO: fix it!
|
// TODO: fix it!
|
||||||
try {
|
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) {
|
if (result.length <= 1) {
|
||||||
return next(new ErrorDTO(ErrorCodes.GENERAL_ERROR));
|
return next(new ErrorDTO(ErrorCodes.GENERAL_ERROR));
|
||||||
}
|
}
|
||||||
|
@ -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();
|
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> {
|
public async createUser(user: UserDTO): Promise<any> {
|
||||||
|
Loading…
Reference in New Issue
Block a user