feat: add simple login logic

This commit is contained in:
2026-02-18 09:13:23 +03:30
parent b9779f7cb6
commit e657264807
16 changed files with 259 additions and 13 deletions
+1 -1
View File
@@ -104,7 +104,7 @@ export class CreateUserDTO {
@MaxLength(96, {
message: t('validation.maxLengthField', {
field: '$t(users.fields.password)',
min: 96,
max: 96,
}),
})
@Matches(/^(?=.*[A-Za-z])(?=.*\d)(?=.*[^A-Za-z\d]).{8,}$/, {
@@ -14,6 +14,17 @@ export class UsersService {
private readonly userRepository: Repository<User>,
) {}
public async findOneByPhone(phone: string) {
try {
return await this.userRepository.findOneBy({ phone });
} catch (err) {
throw new RequestTimeoutException(
'Unable to process your request at the moment. Please try again later.',
{ cause: err, description: 'Error connecting to the database' },
);
}
}
public async createOne(createUserDto: CreateUserDTO) {
const newUser = this.userRepository.create(createUserDto);
+6 -6
View File
@@ -14,16 +14,16 @@ export class User {
@Column({
type: 'varchar',
length: 96,
nullable: false,
nullable: true,
})
firstName: string;
firstName?: string;
@Column({
type: 'varchar',
length: 96,
nullable: false,
nullable: true,
})
lastName: string;
lastName?: string;
@Column({
type: 'varchar',
@@ -36,9 +36,9 @@ export class User {
@Column({
type: 'varchar',
length: 96,
nullable: false,
nullable: true,
})
password: string;
password?: string;
@CreateDateColumn()
createdAt: Date;
+1
View File
@@ -8,5 +8,6 @@ import { User } from './user.entity';
imports: [TypeOrmModule.forFeature([User])],
controllers: [UsersController],
providers: [UsersService],
exports: [UsersService],
})
export class UsersModule {}