From 95dfc551f7eaaf6e8ebdefce1b733951354ac40d Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Sun, 3 Sep 2023 15:00:03 +0530 Subject: added JWT authorization middleware --- errors/status.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'errors/status.go') diff --git a/errors/status.go b/errors/status.go index b0da1ae..4767aeb 100644 --- a/errors/status.go +++ b/errors/status.go @@ -41,6 +41,14 @@ func StatusCodeFromErr(err error) int { return http.StatusBadRequest } + // 401 + if errors.Is(err, ErrWrongPassword) || + errors.Is(err, ErrUnauthorized) || + errors.Is(err, ErrInvalidAuthHeader) || + errors.Is(err, ErrSessionExpired) { + return http.StatusUnauthorized + } + // 404 if errors.Is(err, ErrNotFound) || errors.Is(err, ErrBrandNotFound) { -- cgit v1.2.3