refactor: change the role to roles and many to many

This commit is contained in:
mahyargdz
2025-02-16 16:58:51 +03:30
parent 9cdd7ef28e
commit ad673613d9
32 changed files with 264 additions and 88 deletions
@@ -11,20 +11,41 @@ export class UserRepository extends Repository<User> {
}
async findOneWithEmail(email: string): Promise<User | null> {
return this.findOneBy({
email,
return this.findOne({
where: {
email,
},
relations: {
roles: {
permissions: true,
},
},
});
}
async findOneWithPhone(phone: string): Promise<User | null> {
return this.findOneBy({
phone,
return this.findOne({
where: {
phone,
},
relations: {
roles: {
permissions: true,
},
},
});
}
async findOneWithUserName(userName: string): Promise<User | null> {
return this.findOneBy({
userName,
return this.findOne({
where: {
userName,
},
relations: {
roles: {
permissions: true,
},
},
});
}
}