use return not use else

This commit is contained in:
thinkerou 2017-07-17 23:46:43 +08:00
parent 8f861946b0
commit 179e58f8a8

View File

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