Merge branch 'master' into add_else

This commit is contained in:
Bo-Yi Wu 2017-07-17 19:55:21 -05:00 committed by GitHub
commit 4e50f50105

10
auth.go
View File

@ -52,11 +52,13 @@ func BasicAuthForRealm(accounts Accounts, realm string) HandlerFunc {
// Credentials doesn't match, we return 401 and abort handlers chain.
c.Header("WWW-Authenticate", realm)
c.AbortWithStatus(401)
} else {
// The user credentials was found, set user's id to key AuthUserKey in this context, the userId can be read later using
// c.MustGet(gin.AuthUserKey)
c.Set(AuthUserKey, user)
return
}
// The user credentials was found, set user's id to key AuthUserKey in this context, the user's id can be read later using
// c.MustGet(gin.AuthUserKey)
c.Set(AuthUserKey, user)
return
}
}