mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 02:08:36 +00:00
Allow disabling authentication related user features (#31535)
We have some instances that only allow using an external authentication source for authentication. In this case, users changing their email, password, or linked OpenID connections will not have any effect, and we'd like to prevent showing that to them to prevent confusion. Included in this are several changes to support this: * A new setting to disable user managed authentication credentials (email, password & OpenID connections) * A new setting to disable user managed MFA (2FA codes & WebAuthn) * Fix an issue where some templates had separate logic for determining if a feature was disabled since it didn't check the globally disabled features * Hide more user setting pages in the navbar when their settings aren't enabled --------- Co-authored-by: Kyle D <kdumontnu@gmail.com>
This commit is contained in:
@@ -1263,12 +1263,14 @@ func GetOrderByName() string {
|
||||
return "name"
|
||||
}
|
||||
|
||||
// IsFeatureDisabledWithLoginType checks if a user feature is disabled, taking into account the login type of the
|
||||
// IsFeatureDisabledWithLoginType checks if a user features are disabled, taking into account the login type of the
|
||||
// user if applicable
|
||||
func IsFeatureDisabledWithLoginType(user *User, feature string) bool {
|
||||
func IsFeatureDisabledWithLoginType(user *User, features ...string) bool {
|
||||
// NOTE: in the long run it may be better to check the ExternalLoginUser table rather than user.LoginType
|
||||
return (user != nil && user.LoginType > auth.Plain && setting.Admin.ExternalUserDisableFeatures.Contains(feature)) ||
|
||||
setting.Admin.UserDisabledFeatures.Contains(feature)
|
||||
if user != nil && user.LoginType > auth.Plain {
|
||||
return setting.Admin.ExternalUserDisableFeatures.Contains(features...)
|
||||
}
|
||||
return setting.Admin.UserDisabledFeatures.Contains(features...)
|
||||
}
|
||||
|
||||
// DisabledFeaturesWithLoginType returns the set of user features disabled, taking into account the login type
|
||||
|
Reference in New Issue
Block a user