diff options
author | Joe Chen <jc@unknwon.io> | 2022-11-27 15:53:26 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-27 15:53:26 +0800 |
commit | 44333afd20a6312b617e0c33a497a4385ba3a250 (patch) | |
tree | 08550527657f6af16fab8d42b863cda4c34da095 /internal/route/user/auth.go | |
parent | 13099a7e4fe7565bb858646d42d1fba817cb06cc (diff) |
chore: consistently use `errors.Cause` for identifying error types (#7264)
Diffstat (limited to 'internal/route/user/auth.go')
-rw-r--r-- | internal/route/user/auth.go | 7 |
1 files changed, 3 insertions, 4 deletions
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) |