Skip to content

Commit

Permalink
fix: email to lowercase
Browse files Browse the repository at this point in the history
  • Loading branch information
tassyla committed Jan 27, 2025
1 parent 6788ec8 commit 5ca7785
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/modules/users/infra/http/routes/users.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const storage = multer.memoryStorage();
const upload = multer({ storage: storage});

usersRoutes.post('/register', usersController.create);
usersRoutes.patch('/update',upload.single('image'), ensureAuthenticated, usersController.update);
usersRoutes.patch('/update', upload.single('image'), ensureAuthenticated, usersController.update);
usersRoutes.delete('/delete', ensureAuthenticated, usersController.delete);
usersRoutes.get('/readAll', usersController.readAll);
usersRoutes.get('/read', ensureAuthenticated, usersController.readById);
Expand Down
2 changes: 1 addition & 1 deletion src/modules/users/services/AuthenticateUserService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default class AuthenticateUserService {
) { }

public async execute({ email, password, rememberMe }: IRequest): Promise<{ user: Users, token: string }> {
const user = await this.usersRepository.findByEmailWithRelations(email);
const user = await this.usersRepository.findByEmailWithRelations(email.toLocaleLowerCase());

if (!user) {
throw new AppError('Incorrect email/password combination', 401);
Expand Down
2 changes: 1 addition & 1 deletion src/modules/users/services/UpdateUserService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default class UpdateUserService {

if (!userAlreadyExists) throw new AppError('User with this id does not exist');
if (updateData.email) {
const userWithUpdatedEmail = await this.usersRepository.findByEmailWithRelations(updateData.email);
const userWithUpdatedEmail = await this.usersRepository.findByEmailWithRelations(updateData.email.toLowerCase());
if (userWithUpdatedEmail) {
if (userWithUpdatedEmail.id == id) {
throw new AppError('You cannot update your email to the same email');
Expand Down

0 comments on commit 5ca7785

Please sign in to comment.