mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-08-28 05:03:51 +00:00
chore(cleanup): replaces unnecessary calls to formatting functions by non-formatting equivalents (#7994)
This PR replaces unnecessary calls to formatting functions (`fmt.Printf`, `fmt.Errorf`, ...) by non-formatting equivalents. Resolves #7967 Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7994 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Co-authored-by: chavacava <chavacava@noreply.codeberg.org> Co-committed-by: chavacava <chavacava@noreply.codeberg.org>
This commit is contained in:
parent
25f3f8e1d2
commit
99d697263f
126 changed files with 340 additions and 281 deletions
|
@ -4,6 +4,7 @@
|
|||
package packages
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
@ -53,7 +54,7 @@ func ParseAuthorizationToken(req *http.Request) (int64, auth_model.AccessTokenSc
|
|||
parts := strings.SplitN(h, " ", 2)
|
||||
if len(parts) != 2 {
|
||||
log.Error("split token failed: %s", h)
|
||||
return 0, "", fmt.Errorf("split token failed")
|
||||
return 0, "", errors.New("split token failed")
|
||||
}
|
||||
|
||||
token, err := jwt.ParseWithClaims(parts[1], &packageClaims{}, func(t *jwt.Token) (any, error) {
|
||||
|
@ -68,7 +69,7 @@ func ParseAuthorizationToken(req *http.Request) (int64, auth_model.AccessTokenSc
|
|||
|
||||
c, ok := token.Claims.(*packageClaims)
|
||||
if !token.Valid || !ok {
|
||||
return 0, "", fmt.Errorf("invalid token claim")
|
||||
return 0, "", errors.New("invalid token claim")
|
||||
}
|
||||
|
||||
return c.UserID, c.Scope, nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue