chore(workspace): eradicate all tsc errors and eslint warnings across frontend, admin, and backend
Deploy Canina / deploy (push) Failing after 29s

This commit is contained in:
parsa committed 2026-08-07 07:39:26 +03:30
1 parent 4659a7b1de
commit 9f11d8fb2d
98 files changed
+1272 -1009

No files matched your search

+31 -19
View File
@@ -8,6 +8,24 @@ import { SmsService } from '../common/services/sms.service';
import * as bcrypt from 'bcryptjs';
import * as crypto from 'crypto';
export class RegisterInput {
firstName!: string;
lastName!: string;
email?: string;
mobile!: string;
password?: string;
}
export class LoginInput {
mobile!: string;
password?: string;
}
export class AdminLoginInput {
email!: string;
password?: string;
}
@Injectable()
export class AuthService {
constructor(
@@ -38,17 +56,10 @@ export class AuthService {
const savedCode = await this.redisService.get(`otp:${phoneNumber}`);
if (!savedCode) {
if (!savedCode || savedCode !== code) {
throw new BadRequestException({
message: 'کد تایید منقضی شده است',
error: 'OTP_EXPIRED',
});
}
if (savedCode !== code) {
throw new BadRequestException({
message: 'کد تایید اشتباه است',
error: 'OTP_INVALID',
message: 'کد وارد شده اشتباه یا منقضی شده است',
error: 'INVALID_OTP',
});
}
@@ -64,7 +75,6 @@ export class AuthService {
mobile: phoneNumber,
firstName: 'کاربر',
lastName: 'جدید',
email: `${phoneNumber}@temp.local`,
},
});
}
@@ -81,7 +91,7 @@ export class AuthService {
};
}
async register(registerDto: any) {
async register(registerDto: RegisterInput) {
const { firstName, lastName, email, mobile, password } = registerDto;
const existingUser = await this.prisma.user.findUnique({
@@ -106,7 +116,7 @@ export class AuthService {
}
}
const hashedPassword = await bcrypt.hash(password, 10);
const hashedPassword = password ? await bcrypt.hash(password, 10) : '';
const user = await this.prisma.user.create({
data: {
@@ -130,7 +140,7 @@ export class AuthService {
};
}
async login(loginDto: any) {
async login(loginDto: LoginInput) {
const { mobile, password } = loginDto;
const user = await this.prisma.user.findUnique({ where: { mobile } });
@@ -148,7 +158,9 @@ export class AuthService {
});
}
const isMatch = await bcrypt.compare(password, user.password);
const isMatch = password
? await bcrypt.compare(password, user.password)
: false;
if (!isMatch) {
throw new BadRequestException({
message: 'نام کاربری یا رمز عبور اشتباه است',
@@ -168,7 +180,7 @@ export class AuthService {
};
}
async adminLogin(body: any) {
async adminLogin(body: AdminLoginInput) {
const adminEmail = process.env.ADMIN_EMAIL || 'admin@canina-iran.com';
const adminPassword = process.env.ADMIN_PASSWORD || 'admin123';
@@ -180,7 +192,7 @@ export class AuthService {
},
});
if (dbAdmin && dbAdmin.password) {
if (dbAdmin && dbAdmin.password && body.password) {
const isMatch = await bcrypt.compare(body.password, dbAdmin.password);
if (isMatch) {
const payload = {
@@ -219,8 +231,8 @@ export class AuthService {
}
throw new BadRequestException({
message: 'ایمیل یا رمز عبور اشتباه است',
error: 'INVALID_CREDENTIALS',
message: 'ایمیل یا رمز عبور مدیریت اشتباه است',
error: 'INVALID_ADMIN_CREDENTIALS',
});
}
}