🚀 Fix: Login case-sensitivity & Restore Super Admin AI metrics access
This commit is contained in:
@@ -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'],
|
||||
});
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user