using Kurs.Platform.Identity; using Kurs.Platform.Localization; using System; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using Volo.Abp.Localization; using Volo.Abp.ObjectExtending; using Volo.Abp.Threading; namespace Kurs.Platform; public static class PlatformModuleExtensionConfigurator { private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner(); public static void Configure() { OneTimeRunner.Run(() => { ConfigureExistingProperties(); ConfigureExtraProperties(); }); } private static void ConfigureExistingProperties() { /* You can change max lengths for properties of the * entities defined in the modules used by your application. * * Example: Change user and role name max lengths AbpUserConsts.MaxNameLength = 99; IdentityRoleConsts.MaxNameLength = 99; * Notice: It is not suggested to change property lengths * unless you really need it. Go with the standard values wherever possible. * * If you are using EF Core, you will need to run the add-migration command after your changes. */ } private static void ConfigureExtraProperties() { ObjectExtensionManager.Instance.Modules() .ConfigureIdentity(identity => { identity.ConfigureUser(user => { user.AddOrUpdateProperty( PlatformConsts.AbpIdentity.User.IsVerified, property => { property.Attributes.Add(new RequiredAttribute()); property.Attributes.Add(new DefaultValueAttribute(false)); property.DisplayName = new LocalizableString(typeof(PlatformResource), PlatformConsts.AbpIdentity.User.IsVerified); //property.UI.OnEditForm.IsVisible = true; //property.UI.OnCreateForm.IsVisible = true; //property.UI.OnTable.IsVisible = true; property.IsAvailableToClients = false; property.Configuration[IdentityModuleExtensionConsts.ConfigurationNames.AllowUserToEdit] = false; }); user.AddOrUpdateProperty( PlatformConsts.AbpIdentity.User.LoginEndDate, property => { property.DisplayName = new LocalizableString(typeof(PlatformResource), PlatformConsts.AbpIdentity.User.LoginEndDate); property.IsAvailableToClients = false; property.Configuration[IdentityModuleExtensionConsts.ConfigurationNames.AllowUserToEdit] = false; }); user.AddOrUpdateProperty( PlatformConsts.AbpIdentity.User.RocketUsername, property => { property.DisplayName = new LocalizableString(typeof(PlatformResource), PlatformConsts.AbpIdentity.User.RocketUsername); }); }); }); ObjectExtensionManager.Instance.Modules() .ConfigureTenantManagement(tenantConfig => { tenantConfig.ConfigureTenant(entity => { entity.AddOrUpdateProperty("IsActive"); }); }); /* You can configure extra properties for the * entities defined in the modules used by your application. * * This class can be used to define these extra properties * with a high level, easy to use API. * * Example: Add a new property to the user entity of the identity module ObjectExtensionManager.Instance.Modules() .ConfigureIdentity(identity => { identity.ConfigureUser(user => { user.AddOrUpdateProperty( //property type: string "SocialSecurityNumber", //property name property => { //validation rules property.Attributes.Add(new RequiredAttribute()); property.Attributes.Add(new StringLengthAttribute(64) {MinimumLength = 4}); property.Configuration[IdentityModuleExtensionConsts.ConfigurationNames.AllowUserToEdit] = true; //...other configurations for this property } ); }); }); * See the documentation for more: * https://docs.abp.io/en/abp/latest/Module-Entity-Extensions */ } }