aboutsummaryrefslogtreecommitdiff
path: root/internal/route
diff options
context:
space:
mode:
Diffstat (limited to 'internal/route')
-rw-r--r--internal/route/lfs/route.go7
-rw-r--r--internal/route/org/setting.go5
-rw-r--r--internal/route/repo/http.go7
-rw-r--r--internal/route/repo/view.go3
-rw-r--r--internal/route/user/auth.go7
5 files changed, 12 insertions, 17 deletions
diff --git a/internal/route/lfs/route.go b/internal/route/lfs/route.go
index b2ab2b0c..3440c89b 100644
--- a/internal/route/lfs/route.go
+++ b/internal/route/lfs/route.go
@@ -8,7 +8,6 @@ import (
"net/http"
"strings"
- "github.com/pkg/errors"
"gopkg.in/macaron.v1"
log "unknwon.dev/clog/v2"
@@ -76,15 +75,15 @@ func authenticate() macaron.Handler {
// or password as the token.
if auth.IsErrBadCredentials(err) {
user, err = context.AuthenticateByToken(c.Req.Context(), username)
- if err != nil && !db.IsErrAccessTokenNotExist(errors.Cause(err)) {
+ if err != nil && !db.IsErrAccessTokenNotExist(err) {
internalServerError(c.Resp)
log.Error("Failed to authenticate by access token via username: %v", err)
return
- } else if db.IsErrAccessTokenNotExist(errors.Cause(err)) {
+ } else if db.IsErrAccessTokenNotExist(err) {
// Try again using the password field as the token.
user, err = context.AuthenticateByToken(c.Req.Context(), password)
if err != nil {
- if db.IsErrAccessTokenNotExist(errors.Cause(err)) {
+ if db.IsErrAccessTokenNotExist(err) {
askCredentials(c.Resp)
} else {
c.Status(http.StatusInternalServerError)
diff --git a/internal/route/org/setting.go b/internal/route/org/setting.go
index bcef4ea1..0cfc2454 100644
--- a/internal/route/org/setting.go
+++ b/internal/route/org/setting.go
@@ -5,7 +5,6 @@
package org
import (
- "github.com/pkg/errors"
log "unknwon.dev/clog/v2"
"gogs.io/gogs/internal/auth"
@@ -45,9 +44,9 @@ func SettingsPost(c *context.Context, f form.UpdateOrgSetting) {
c.Data["OrgName"] = true
var msg string
switch {
- case db.IsErrUserAlreadyExist(errors.Cause(err)):
+ case db.IsErrUserAlreadyExist(err):
msg = c.Tr("form.username_been_taken")
- case db.IsErrNameNotAllowed(errors.Cause(err)):
+ case db.IsErrNameNotAllowed(err):
msg = c.Tr("user.form.name_not_allowed", err.(db.ErrNameNotAllowed).Value())
default:
c.Error(err, "change organization name")
diff --git a/internal/route/repo/http.go b/internal/route/repo/http.go
index e8e1ac15..96ac22e0 100644
--- a/internal/route/repo/http.go
+++ b/internal/route/repo/http.go
@@ -17,7 +17,6 @@ import (
"strings"
"time"
- "github.com/pkg/errors"
"gopkg.in/macaron.v1"
log "unknwon.dev/clog/v2"
@@ -136,15 +135,15 @@ func HTTPContexter() macaron.Handler {
// or password as the token.
if authUser == nil {
authUser, err = context.AuthenticateByToken(c.Req.Context(), authUsername)
- if err != nil && !db.IsErrAccessTokenNotExist(errors.Cause(err)) {
+ if err != nil && !db.IsErrAccessTokenNotExist(err) {
c.Status(http.StatusInternalServerError)
log.Error("Failed to authenticate by access token via username: %v", err)
return
- } else if db.IsErrAccessTokenNotExist(errors.Cause(err)) {
+ } else if db.IsErrAccessTokenNotExist(err) {
// Try again using the password field as the token.
authUser, err = context.AuthenticateByToken(c.Req.Context(), authPassword)
if err != nil {
- if db.IsErrAccessTokenNotExist(errors.Cause(err)) {
+ if db.IsErrAccessTokenNotExist(err) {
askCredentials(c, http.StatusUnauthorized, "")
} else {
c.Status(http.StatusInternalServerError)
diff --git a/internal/route/repo/view.go b/internal/route/repo/view.go
index 89d6f86d..f4b6a162 100644
--- a/internal/route/repo/view.go
+++ b/internal/route/repo/view.go
@@ -13,7 +13,6 @@ import (
"time"
"github.com/gogs/git-module"
- "github.com/pkg/errors"
"github.com/unknwon/paginater"
log "unknwon.dev/clog/v2"
@@ -221,7 +220,7 @@ func renderFile(c *context.Context, entry *git.TreeEntry, treeLink, rawLink stri
func setEditorconfigIfExists(c *context.Context) {
ec, err := c.Repo.Editorconfig()
- if err != nil && !gitutil.IsErrRevisionNotExist(errors.Cause(err)) {
+ if err != nil && !gitutil.IsErrRevisionNotExist(err) {
log.Warn("setEditorconfigIfExists.Editorconfig [repo_id: %d]: %v", c.Repo.Repository.ID, err)
return
}
diff --git a/internal/route/user/auth.go b/internal/route/user/auth.go
index 1977fe17..8e63d914 100644
--- a/internal/route/user/auth.go
+++ b/internal/route/user/auth.go
@@ -12,7 +12,6 @@ import (
"net/url"
"github.com/go-macaron/captcha"
- "github.com/pkg/errors"
"github.com/unknwon/com"
log "unknwon.dev/clog/v2"
@@ -168,11 +167,11 @@ func LoginPost(c *context.Context, f form.SignIn) {
u, err := db.Users.Authenticate(c.Req.Context(), f.UserName, f.Password, f.LoginSource)
if err != nil {
- switch errors.Cause(err).(type) {
- case auth.ErrBadCredentials:
+ switch {
+ case auth.IsErrBadCredentials(err):
c.FormErr("UserName", "Password")
c.RenderWithErr(c.Tr("form.username_password_incorrect"), LOGIN, &f)
- case db.ErrLoginSourceMismatch:
+ case db.IsErrLoginSourceMismatch(err):
c.FormErr("LoginSource")
c.RenderWithErr(c.Tr("form.auth_source_mismatch"), LOGIN, &f)