diff options
author | Vidhu Kant Sharma <vidhukant@vidhukant.com> | 2023-09-03 15:00:03 +0530 |
---|---|---|
committer | Vidhu Kant Sharma <vidhukant@vidhukant.com> | 2023-09-03 15:00:03 +0530 |
commit | 95dfc551f7eaaf6e8ebdefce1b733951354ac40d (patch) | |
tree | ecabef39a94084c456eaf32bb508d8809d592c9f /errors/status.go | |
parent | fc83df70b787e447bf31f4d99fa723c7e38544f2 (diff) |
added JWT authorization middleware
Diffstat (limited to 'errors/status.go')
-rw-r--r-- | errors/status.go | 8 |
1 files changed, 8 insertions, 0 deletions
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) { |