mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
try to solve problem of dbUser-entity with emailContact in context
This commit is contained in:
parent
0f90f960ce
commit
1184666fe2
@ -31,7 +31,7 @@ const isAuthorized: AuthChecker<any> = async ({ context }, rights) => {
|
||||
|
||||
// TODO - load from database dynamically & admin - maybe encode this in the token to prevent many database requests
|
||||
// TODO this implementation is bullshit - two database queries cause our user identifiers are not aligned and vary between email, id and pubKey
|
||||
const userRepository = await getCustomRepository(UserRepository)
|
||||
const userRepository = getCustomRepository(UserRepository)
|
||||
try {
|
||||
const user = await userRepository.findByPubkeyHex(context.pubKey)
|
||||
context.user = user
|
||||
|
||||
@ -1,12 +1,20 @@
|
||||
import { Brackets, EntityRepository, ObjectLiteral, Repository } from '@dbTools/typeorm'
|
||||
import { User } from '@entity/User'
|
||||
import { User as DbUser } from '@entity/User'
|
||||
|
||||
@EntityRepository(User)
|
||||
export class UserRepository extends Repository<User> {
|
||||
async findByPubkeyHex(pubkeyHex: string): Promise<User> {
|
||||
return await this.createQueryBuilder('user')
|
||||
@EntityRepository(DbUser)
|
||||
export class UserRepository extends Repository<DbUser> {
|
||||
async findByPubkeyHex(pubkeyHex: string): Promise<DbUser> {
|
||||
const dbUser = await this.createQueryBuilder('user')
|
||||
.where('hex(user.pubKey) = :pubkeyHex', { pubkeyHex })
|
||||
.getOneOrFail()
|
||||
/*
|
||||
const dbUser = await this.findOneOrFail(`hex(user.pubKey) = { pubkeyHex }`)
|
||||
const emailContact = await this.query(
|
||||
`SELECT * from user_contacts where id = { dbUser.emailId }`,
|
||||
)
|
||||
dbUser.emailContact = emailContact
|
||||
*/
|
||||
return dbUser
|
||||
}
|
||||
|
||||
async findBySearchCriteriaPagedFiltered(
|
||||
@ -15,7 +23,7 @@ export class UserRepository extends Repository<User> {
|
||||
filterCriteria: ObjectLiteral[],
|
||||
currentPage: number,
|
||||
pageSize: number,
|
||||
): Promise<[User[], number]> {
|
||||
): Promise<[DbUser[], number]> {
|
||||
const query = await this.createQueryBuilder('user')
|
||||
.select(select)
|
||||
.withDeleted()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user