use return not use else (#1028)

This commit is contained in:
田欧 2017-07-18 08:54:38 +08:00 committed by Bo-Yi Wu
parent 8f861946b0
commit b539606eed
1 changed files with 6 additions and 4 deletions

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
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
}
}