diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2021-11-24 17:49:20 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-24 17:49:20 +0800 |
commit | a666829a37be6f9fd98f9e7dd1767c420f7f3b32 (patch) | |
tree | 9ab1434b759a8a2cb275a83149903a823851e309 /services/auth/reverseproxy.go | |
parent | 4e7ca946da2a2642a62f114825129bf5d7ed9196 (diff) | |
download | gitea-a666829a37be6f9fd98f9e7dd1767c420f7f3b32.tar.gz gitea-a666829a37be6f9fd98f9e7dd1767c420f7f3b32.zip |
Move user related model into models/user (#17781)
* Move user related model into models/user
* Fix lint for windows
* Fix windows lint
* Fix windows lint
* Move some tests in models
* Merge
Diffstat (limited to 'services/auth/reverseproxy.go')
-rw-r--r-- | services/auth/reverseproxy.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/services/auth/reverseproxy.go b/services/auth/reverseproxy.go index 7cd24c302d..3e44d8b863 100644 --- a/services/auth/reverseproxy.go +++ b/services/auth/reverseproxy.go @@ -9,7 +9,7 @@ import ( "net/http" "strings" - "code.gitea.io/gitea/models" + user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/web/middleware" @@ -56,16 +56,16 @@ func (r *ReverseProxy) Name() string { // If a username is available in the "setting.ReverseProxyAuthUser" header an existing // user object is returned (populated with username or email found in header). // Returns nil if header is empty. -func (r *ReverseProxy) Verify(req *http.Request, w http.ResponseWriter, store DataStore, sess SessionStore) *models.User { +func (r *ReverseProxy) Verify(req *http.Request, w http.ResponseWriter, store DataStore, sess SessionStore) *user_model.User { username := r.getUserName(req) if len(username) == 0 { return nil } log.Trace("ReverseProxy Authorization: Found username: %s", username) - user, err := models.GetUserByName(username) + user, err := user_model.GetUserByName(username) if err != nil { - if !models.IsErrUserNotExist(err) || !r.isAutoRegisterAllowed() { + if !user_model.IsErrUserNotExist(err) || !r.isAutoRegisterAllowed() { log.Error("GetUserByName: %v", err) return nil } @@ -91,7 +91,7 @@ func (r *ReverseProxy) isAutoRegisterAllowed() bool { // newUser creates a new user object for the purpose of automatic registration // and populates its name and email with the information present in request headers. -func (r *ReverseProxy) newUser(req *http.Request) *models.User { +func (r *ReverseProxy) newUser(req *http.Request) *user_model.User { username := r.getUserName(req) if len(username) == 0 { return nil @@ -105,12 +105,12 @@ func (r *ReverseProxy) newUser(req *http.Request) *models.User { } } - user := &models.User{ + user := &user_model.User{ Name: username, Email: email, IsActive: true, } - if err := models.CreateUser(user); err != nil { + if err := user_model.CreateUser(user); err != nil { // FIXME: should I create a system notice? log.Error("CreateUser: %v", err) return nil |