Skip to content

Commit

Permalink
fix: minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
yousefyasser committed Oct 6, 2024
1 parent f009ef2 commit 1890430
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions backend/src/controllers/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ class AuthController {
try {
Validator.validatePassword(req.body.password);

const userId = await AuthRepo.register(req.body);
const token = AuthService.generateAccessToken({ userId: userId, accountType: req.body.account_type });
const user = await AuthRepo.register(req.body);
const token = AuthService.generateAccessToken({ userId: user.id, accountType: req.body.account_type });

res.send({ message: 'User registered successfully', data: { jwt: token } });
res.send({ message: 'User registered successfully', data: { user: user, jwt: token } });
} catch (error: any) {
logger.error(`Error creating user: ${error}`);
res.status(ResponseStatusCodes.BAD_REQUEST).send({ message: error.message, data: null });
Expand Down
2 changes: 1 addition & 1 deletion backend/src/database/repositories/auth/auth.repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { User } from '../../models/user.model';
class AuthRepo {
async register(user: UserType) {
const newUser = await User.create(user);
return newUser.id;
return newUser;
}
}

Expand Down

0 comments on commit 1890430

Please sign in to comment.