mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-09-24 19:40:58 +00:00
Drop error only on purpose or else report back or log (#514)
- Remove Deadcode - Simplify Code - Drop error only on purpose
This commit is contained in:
@@ -104,7 +104,10 @@ func SetPerm() gin.HandlerFunc {
|
||||
perm.Repo = repo.FullName
|
||||
perm.UserID = user.ID
|
||||
perm.Synced = time.Now().Unix()
|
||||
store_.PermUpsert(perm)
|
||||
if err := store_.PermUpsert(perm); err != nil {
|
||||
_ = c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -78,7 +78,7 @@ func MustAdmin() gin.HandlerFunc {
|
||||
case user == nil:
|
||||
c.String(401, "User not authorized")
|
||||
c.Abort()
|
||||
case user.Admin == false:
|
||||
case !user.Admin:
|
||||
c.String(403, "User not authorized")
|
||||
c.Abort()
|
||||
default:
|
||||
@@ -95,7 +95,7 @@ func MustRepoAdmin() gin.HandlerFunc {
|
||||
case user == nil:
|
||||
c.String(401, "User not authorized")
|
||||
c.Abort()
|
||||
case perm.Admin == false:
|
||||
case !perm.Admin:
|
||||
c.String(403, "User not authorized")
|
||||
c.Abort()
|
||||
default:
|
||||
|
@@ -53,8 +53,10 @@ func Refresh(c *gin.Context) {
|
||||
// attempts to refresh the access token. If the
|
||||
// token is refreshed, we must also persist to the
|
||||
// database.
|
||||
ok, _ = refresher.Refresh(c, user)
|
||||
if ok {
|
||||
ok, err := refresher.Refresh(c, user)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msgf("refresh oauth token of user '%s' failed", user.Login)
|
||||
} else if ok {
|
||||
err := store.FromContext(c).UpdateUser(user)
|
||||
if err != nil {
|
||||
// we only log the error at this time. not sure
|
||||
|
Reference in New Issue
Block a user