Fix bug in deletionkeys

This commit is contained in:
rubikscraft 2022-09-03 21:08:28 +02:00
parent 92e44aea66
commit ec3e58d1b2
No known key found for this signature in database
GPG key ID: 1463EBE9200A5CD4
4 changed files with 12 additions and 8 deletions

View file

@ -33,12 +33,15 @@ export class ImageDBService {
if (withDeleteKey) imageEntity.delete_key = generateRandomString(32); if (withDeleteKey) imageEntity.delete_key = generateRandomString(32);
try { try {
imageEntity = await this.imageRepo.save(imageEntity, { reload: true }); imageEntity = await this.imageRepo.save(imageEntity, {
reload: true,
});
if (imageEntity.delete_key === null) delete imageEntity.delete_key;
return imageEntity;
} catch (e) { } catch (e) {
return Fail(FT.Database, e); return Fail(FT.Database, e);
} }
return imageEntity;
} }
public async findOne( public async findOne(

View file

@ -141,6 +141,7 @@ export class RoleDbService {
try { try {
const found = await this.rolesRepository.find({ const found = await this.rolesRepository.find({
where: { name: In(names) }, where: { name: In(names) },
order: { name: 'ASC' },
}); });
if (!found) return Fail(FT.NotFound, 'No roles found'); if (!found) return Fail(FT.NotFound, 'No roles found');
@ -152,7 +153,9 @@ export class RoleDbService {
public async findAll(): AsyncFailable<ERoleBackend[]> { public async findAll(): AsyncFailable<ERoleBackend[]> {
try { try {
const found = await this.rolesRepository.find(); const found = await this.rolesRepository.find({
order: { name: 'ASC' },
});
if (!found) return Fail(FT.NotFound, 'No roles found'); if (!found) return Fail(FT.NotFound, 'No roles found');
return found; return found;
} catch (e) { } catch (e) {

View file

@ -224,6 +224,7 @@ export class UserDbService {
const [users, amount] = await this.usersRepository.findAndCount({ const [users, amount] = await this.usersRepository.findAndCount({
take: count, take: count,
skip: count * page, skip: count * page,
order: { username: 'ASC' },
}); });
if (users === undefined) return Fail(FT.NotFound, 'Users not found'); if (users === undefined) return Fail(FT.NotFound, 'Users not found');

View file

@ -24,10 +24,7 @@ export class EImageBackend implements EImage {
@Column({ @Column({
nullable: true, nullable: true,
transformer: { select: false,
from: (value: string | null) => (value === null ? undefined : value),
to: (value: string | undefined) => (value === undefined ? null : value),
},
}) })
delete_key?: string; delete_key?: string;
} }