diff options
Diffstat (limited to 'internal/context/auth.go')
-rw-r--r-- | internal/context/auth.go | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/internal/context/auth.go b/internal/context/auth.go index 775a3dd8..73a362c6 100644 --- a/internal/context/auth.go +++ b/internal/context/auth.go @@ -175,7 +175,7 @@ func authenticatedUser(ctx *macaron.Context, sess session.Store) (_ *db.User, is if conf.Auth.EnableReverseProxyAuthentication { webAuthUser := ctx.Req.Header.Get(conf.Auth.ReverseProxyAuthenticationHeader) if len(webAuthUser) > 0 { - u, err := db.GetUserByName(webAuthUser) + user, err := db.GetUserByName(webAuthUser) if err != nil { if !db.IsErrUserNotExist(err) { log.Error("Failed to get user by name: %v", err) @@ -184,22 +184,21 @@ func authenticatedUser(ctx *macaron.Context, sess session.Store) (_ *db.User, is // Check if enabled auto-registration. if conf.Auth.EnableReverseProxyAutoRegistration { - u := &db.User{ - Name: webAuthUser, - Email: gouuid.NewV4().String() + "@localhost", - Password: webAuthUser, - IsActive: true, - } - if err = db.CreateUser(u); err != nil { - // FIXME: should I create a system notice? - log.Error("Failed to create user: %v", err) + user, err = db.Users.Create( + ctx.Req.Context(), + webAuthUser, + gouuid.NewV4().String()+"@localhost", + db.CreateUserOptions{ + Activated: true, + }, + ) + if err != nil { + log.Error("Failed to create user %q: %v", webAuthUser, err) return nil, false, false - } else { - return u, false, false } } } - return u, false, false + return user, false, false } } |