🚀 Fix: Login case-sensitivity & Restore Super Admin AI metrics access

This commit is contained in:
Hamza-Ayed
2026-04-22 22:37:48 +03:00
parent f72c13f29a
commit 944c82730d
6 changed files with 20 additions and 8 deletions

View File

@@ -100,8 +100,9 @@ export class AuthService {
* تسجيل دخول
*/
async login(dto: LoginDto) {
const normalizedEmail = dto.email.trim().toLowerCase();
const user = await this.dataSource.getRepository(User).findOne({
where: { email: dto.email, is_active: true },
where: { email: normalizedEmail, is_active: true },
select: ['id', 'email', 'password_hash', 'tenant_id', 'role', 'name'],
});

View File

@@ -21,8 +21,9 @@ export class UsersService {
* إضافة مستخدم لمكتب محاسبة
*/
async create(tenantId: string, dto: any): Promise<User> {
const normalizedEmail = dto.email?.trim().toLowerCase();
const existing = await this.userRepository.findOne({
where: { email: dto.email, tenant_id: tenantId },
where: { email: normalizedEmail, tenant_id: tenantId },
});
if (existing) {
@@ -33,6 +34,7 @@ export class UsersService {
const user = this.userRepository.create({
...dto,
email: normalizedEmail,
password_hash: passwordHash,
tenant_id: tenantId,
} as Partial<User>);
@@ -85,6 +87,10 @@ export class UsersService {
delete dto.password;
}
if (dto.email) {
dto.email = dto.email.trim().toLowerCase();
}
Object.assign(user, dto);
try {