From 9020faa3ce6c3ba08e138695a5d876bb915279dc Mon Sep 17 00:00:00 2001 From: Jimmy Praet Date: Fri, 1 Apr 2022 19:26:49 +0200 Subject: [PATCH] Apply DefaultUserIsRestricted in CreateUser --- models/user/user.go | 1 + routers/web/auth/auth.go | 9 ++++----- routers/web/auth/oauth.go | 15 +++++++-------- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/models/user/user.go b/models/user/user.go index c848895239..28bae97cba 100644 --- a/models/user/user.go +++ b/models/user/user.go @@ -637,6 +637,7 @@ func CreateUser(u *User, overwriteDefault ...*CreateUserOverwriteOptions) (err e u.EmailNotificationsPreference = setting.Admin.DefaultEmailNotification u.MaxRepoCreation = -1 u.Theme = setting.UI.DefaultTheme + u.IsRestricted = u.IsRestricted || setting.Service.DefaultUserIsRestricted // overwrite defaults if set if len(overwriteDefault) != 0 && overwriteDefault[0] != nil { diff --git a/routers/web/auth/auth.go b/routers/web/auth/auth.go index ab538f0e5f..42cc24aee0 100644 --- a/routers/web/auth/auth.go +++ b/routers/web/auth/auth.go @@ -507,11 +507,10 @@ func SignUpPost(ctx *context.Context) { } u := &user_model.User{ - Name: form.UserName, - Email: form.Email, - Passwd: form.Password, - IsActive: !(setting.Service.RegisterEmailConfirm || setting.Service.RegisterManualConfirm), - IsRestricted: setting.Service.DefaultUserIsRestricted, + Name: form.UserName, + Email: form.Email, + Passwd: form.Password, + IsActive: !(setting.Service.RegisterEmailConfirm || setting.Service.RegisterManualConfirm), } if !createAndHandleCreatedUser(ctx, tplSignUp, form, u, nil, false) { diff --git a/routers/web/auth/oauth.go b/routers/web/auth/oauth.go index 4369c333ac..7e2de79312 100644 --- a/routers/web/auth/oauth.go +++ b/routers/web/auth/oauth.go @@ -867,14 +867,13 @@ func SignInOAuthCallback(ctx *context.Context) { return } u = &user_model.User{ - Name: getUserName(&gothUser), - FullName: gothUser.Name, - Email: gothUser.Email, - IsActive: !setting.OAuth2Client.RegisterEmailConfirm, - LoginType: auth.OAuth2, - LoginSource: authSource.ID, - LoginName: gothUser.UserID, - IsRestricted: setting.Service.DefaultUserIsRestricted, + Name: getUserName(&gothUser), + FullName: gothUser.Name, + Email: gothUser.Email, + IsActive: !setting.OAuth2Client.RegisterEmailConfirm, + LoginType: auth.OAuth2, + LoginSource: authSource.ID, + LoginName: gothUser.UserID, } setUserGroupClaims(authSource, u, &gothUser)