diff options
author | ᴜɴᴋɴᴡᴏɴ <u@gogs.io> | 2020-04-04 21:14:15 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-04 21:14:15 +0800 |
commit | 34145c990d4fd9f278f29cdf9c61378a75e9b934 (patch) | |
tree | 7b151bbd5aef9e487759953e3a775a82244d268d /internal/route/user/auth.go | |
parent | 2bd9d0b9c8238ded727cd98a3ace20b53c10a44f (diff) |
lfs: implement HTTP routes (#6035)
* Bootstrap with GORM
* Fix lint error
* Set conn max lifetime to one minute
* Fallback to use gorm v1
* Define HTTP routes
* Finish authentication
* Save token updated
* Add docstring
* Finish authorization
* serveBatch rundown
* Define types in lfsutil
* Finish Batch
* authutil
* Finish basic
* Formalize response error
* Fix lint errors
* authutil: add tests
* dbutil: add tests
* lfsutil: add tests
* strutil: add tests
* Formalize 401 response
Diffstat (limited to 'internal/route/user/auth.go')
-rw-r--r-- | internal/route/user/auth.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/internal/route/user/auth.go b/internal/route/user/auth.go index a29b6311..22e8176c 100644 --- a/internal/route/user/auth.go +++ b/internal/route/user/auth.go @@ -9,12 +9,12 @@ import ( "net/url" "github.com/go-macaron/captcha" + "github.com/pkg/errors" log "unknwon.dev/clog/v2" "gogs.io/gogs/internal/conf" "gogs.io/gogs/internal/context" "gogs.io/gogs/internal/db" - "gogs.io/gogs/internal/db/errors" "gogs.io/gogs/internal/email" "gogs.io/gogs/internal/form" "gogs.io/gogs/internal/tool" @@ -160,13 +160,13 @@ func LoginPost(c *context.Context, f form.SignIn) { return } - u, err := db.UserLogin(f.UserName, f.Password, f.LoginSource) + u, err := db.Users.Authenticate(f.UserName, f.Password, f.LoginSource) if err != nil { - switch err.(type) { + switch errors.Cause(err).(type) { case db.ErrUserNotExist: c.FormErr("UserName", "Password") c.RenderWithErr(c.Tr("form.username_password_incorrect"), LOGIN, &f) - case errors.LoginSourceMismatch: + case db.ErrLoginSourceMismatch: c.FormErr("LoginSource") c.RenderWithErr(c.Tr("form.auth_source_mismatch"), LOGIN, &f) @@ -263,7 +263,7 @@ func LoginTwoFactorRecoveryCodePost(c *context.Context) { } if err := db.UseRecoveryCode(userID, c.Query("recovery_code")); err != nil { - if errors.IsTwoFactorRecoveryCodeNotFound(err) { + if db.IsTwoFactorRecoveryCodeNotFound(err) { c.Flash.Error(c.Tr("auth.login_two_factor_invalid_recovery_code")) c.RedirectSubpath("/user/login/two_factor_recovery_code") } else { |