feat: add simple login logic
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -8,5 +8,6 @@ import { User } from './user.entity';
|
||||
imports: [TypeOrmModule.forFeature([User])],
|
||||
controllers: [UsersController],
|
||||
providers: [UsersService],
|
||||
exports: [UsersService],
|
||||
})
|
||||
export class UsersModule {}
|
||||
|
||||
Reference in New Issue
Block a user