Skip to content

Commit c86e868

Browse files
Merge pull request #28 from devtron-labs/email-casesensitive-handling
fix: adding email in auth verification
2 parents c772dbd + acb68ad commit c86e868

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

middleware/AuthMiddleware.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const tokenHeaderKey = "token"
3131
const argocdTokenHeaderKey = "argocd.token"
3232

3333
// Authorizer is a middleware for authorization
34-
func Authorizer(sessionManager *SessionManager, whitelistChecker func(url string) bool, userStatusCheckInDb func(token string) (bool, int32, error)) func(next http.Handler) http.Handler {
34+
func Authorizer(sessionManager *SessionManager, whitelistChecker func(url string) bool, userStatusCheckInDb func(token string) (bool, int32, string, error)) func(next http.Handler) http.Handler {
3535
return func(next http.Handler) http.Handler {
3636
fn := func(w http.ResponseWriter, r *http.Request) {
3737
token := ""
@@ -72,18 +72,18 @@ func Authorizer(sessionManager *SessionManager, whitelistChecker func(url string
7272
if userStatusCheckInDb != nil {
7373

7474
// checking user status in db
75-
isInactive, userId, err := userStatusCheckInDb(token)
75+
isInactive, userId, emailId, err := userStatusCheckInDb(token)
7676
if err != nil {
7777
writeResponse(http.StatusUnauthorized, "Invalid User", w, err)
7878
return
7979
} else if isInactive {
8080
writeResponse(http.StatusUnauthorized, "Inactive User", w, fmt.Errorf("inactive User"))
8181
return
8282
}
83-
8483
// setting user id in context
8584
ctx := context.WithValue(r.Context(), "userId", userId)
8685
ctx = context.WithValue(ctx, "token", token)
86+
ctx = context.WithValue(ctx, "emailId", emailId)
8787
r = r.WithContext(ctx)
8888
}
8989
}

0 commit comments

Comments
 (0)