Skip to content

Commit

Permalink
Merge pull request hngprojects#334 from CollinDex/fix/128-User_Soft_D…
Browse files Browse the repository at this point in the history
…elete

Fix: Fixed Auth Middleware
  • Loading branch information
incredible-phoenix246 authored Jul 27, 2024
2 parents debb95b + 3adc8ad commit 5a7cf04
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/middleware/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import config from "../config";
export const authMiddleware = async (
req: Request & { user?: User },
res: Response,
next: NextFunction
next: NextFunction,
) => {
try {
const authHeader = req.headers.authorization;
Expand Down Expand Up @@ -42,7 +42,7 @@ export const authMiddleware = async (
});
}
const user = await User.findOne({
where: { email: decoded["email"] as string },
where: { id: decoded["userId"] as string },
});
if (!user) {
return res.status(401).json({
Expand Down
4 changes: 3 additions & 1 deletion src/services/user.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ export class UserService {
}

public async softDeleteUser(id: string): Promise<UpdateResult> {
const user = await this.userRepository.findOne({ where: { id } });
const user = await this.userRepository.findOne({
where: { id },
});

if (!user) {
throw new HttpError(404, "User Not Found");
Expand Down

0 comments on commit 5a7cf04

Please sign in to comment.