diff --git a/api/src/Kurs.Platform.Application.Contracts/Identity/Dto/AssignedClaimViewModel.cs b/api/src/Kurs.Platform.Application.Contracts/Identity/Dto/AssignedClaimViewModel.cs new file mode 100644 index 00000000..79ef561e --- /dev/null +++ b/api/src/Kurs.Platform.Application.Contracts/Identity/Dto/AssignedClaimViewModel.cs @@ -0,0 +1,14 @@ +using System; + +namespace Kurs.Platform.Identity.Dto; + +public class AssignedClaimViewModel +{ + public Guid Id { get; set; } + + public string ClaimType { get; set; } + + public string ClaimValue { get; set; } + + public bool IsAssigned { get; set; } +} diff --git a/api/src/Kurs.Platform.Application.Contracts/Identity/Dto/UserClaimModel.cs b/api/src/Kurs.Platform.Application.Contracts/Identity/Dto/UserClaimModel.cs new file mode 100644 index 00000000..eb90b02b --- /dev/null +++ b/api/src/Kurs.Platform.Application.Contracts/Identity/Dto/UserClaimModel.cs @@ -0,0 +1,12 @@ +using System; +using Volo.Abp.ObjectExtending; + +namespace Kurs.Platform.Identity.Dto; + +public class UserClaimModel : ExtensibleObject +{ + public Guid Id { get; set; } + public Guid UserId { get; set; } + public string ClaimType { get; set; } + public string ClaimValue { get; set; } +} diff --git a/api/src/Kurs.Platform.Application.Contracts/Identity/Dto/UserInfoViewModel.cs b/api/src/Kurs.Platform.Application.Contracts/Identity/Dto/UserInfoViewModel.cs index d4e9ffc4..009f4836 100644 --- a/api/src/Kurs.Platform.Application.Contracts/Identity/Dto/UserInfoViewModel.cs +++ b/api/src/Kurs.Platform.Application.Contracts/Identity/Dto/UserInfoViewModel.cs @@ -37,6 +37,8 @@ public class UserInfoViewModel: ExtensibleObject public AssignedRoleViewModel[] Roles { get; set; } public AssignedBranchViewModel[] Branches { get; set; } + + public AssignedClaimViewModel[] Claims { get; set; } public bool LockUser { get; set; } diff --git a/api/src/Kurs.Platform.Application/Identity/PlatformIdentityAppService.cs b/api/src/Kurs.Platform.Application/Identity/PlatformIdentityAppService.cs index b5e1e298..f6d92b98 100644 --- a/api/src/Kurs.Platform.Application/Identity/PlatformIdentityAppService.cs +++ b/api/src/Kurs.Platform.Application/Identity/PlatformIdentityAppService.cs @@ -1,13 +1,16 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Security.Claims; using System.Threading.Tasks; using Kurs.Platform.Entities; using Kurs.Platform.Extensions; using Kurs.Platform.Identity.Dto; using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; using Volo.Abp.Application.Services; using Volo.Abp.Domain.Repositories; +using Volo.Abp.Guids; using Volo.Abp.Identity; using Volo.Abp.PermissionManagement; @@ -21,6 +24,8 @@ public class PlatformIdentityAppService : ApplicationService public IRepository permissionRepository { get; } public IRepository branchRepository { get; } public IRepository branchUsersRepository { get; } + public IRepository claimTypesRepository { get; } + public IGuidGenerator guidGenerator { get; } public IdentityUserManager UserManager { get; set; } public PlatformIdentityAppService( @@ -28,7 +33,9 @@ public class PlatformIdentityAppService : ApplicationService IIdentityUserRepository identityUserRepository, IRepository permissionRepository, IRepository branchRepository, - IRepository branchUsersRepository + IRepository branchUsersRepository, + IRepository claimTypesRepository, + IGuidGenerator guidGenerator ) { this.IdentityUserAppService = identityUserAppService; @@ -36,6 +43,8 @@ public class PlatformIdentityAppService : ApplicationService this.permissionRepository = permissionRepository; this.branchRepository = branchRepository; this.branchUsersRepository = branchUsersRepository; + this.claimTypesRepository = claimTypesRepository; + this.guidGenerator = guidGenerator; } public async Task GetByIdAsync(Guid UserId) @@ -52,11 +61,12 @@ public class PlatformIdentityAppService : ApplicationService } } - var query = await branchUsersRepository.GetQueryableAsync(); - var branchUsers = query.Where(a => a.UserId == UserId).Select(r => r.BranchId).ToList(); var currentTenantId = CurrentTenant.Id.HasValue ? CurrentTenant.Id : null; - var branchList = await branchRepository.GetListAsync(a=> a.TenantId == currentTenantId); + //Branch + var queryBranch = await branchUsersRepository.GetQueryableAsync(); + var branchUsers = queryBranch.Where(a => a.UserId == UserId).Select(r => r.BranchId).ToList(); + var branchList = await branchRepository.GetListAsync(a => a.TenantId == currentTenantId); var branches = branchList.Select(branch => new AssignedBranchViewModel { Id = branch.Id, @@ -65,6 +75,21 @@ public class PlatformIdentityAppService : ApplicationService }) .ToArray(); + //Claim + var claimUsers = user.Claims; + var claimList = await claimTypesRepository.GetListAsync(); + var claims = claimList.Select(claim => + { + var userClaim = claimUsers.FirstOrDefault(c => c.ClaimType == claim.Name); + return new AssignedClaimViewModel + { + Id = userClaim?.Id ?? Guid.Empty, + ClaimType = claim.Name, + ClaimValue = userClaim?.ClaimValue, + IsAssigned = userClaim != null + }; + }).ToArray(); + return new UserInfoViewModel() { Id = user.Id, @@ -73,6 +98,7 @@ public class PlatformIdentityAppService : ApplicationService Surname = user.Surname, Roles = roles, Branches = branches, + Claims = claims, Email = user.Email, PhoneNumber = user.PhoneNumber, IsActive = user.IsActive, @@ -177,4 +203,19 @@ public class PlatformIdentityAppService : ApplicationService return [.. list.OrderBy(p => p.Name)]; } + + public async Task CreateClaimUserAsync(UserClaimModel input) + { + var user = await identityUserRepository.GetAsync(input.UserId); + + user.AddClaim(guidGenerator, new Claim(input.ClaimType, input.ClaimValue)); + } + + public async Task DeleteClaimUser(Guid id, Guid userId) + { + var user = await identityUserRepository.GetAsync(userId); + var claim = user.Claims.FirstOrDefault(a => a.Id == id); + + user.Claims.Remove(claim); + } } \ No newline at end of file diff --git a/api/src/Kurs.Platform.DbMigrator/Seeds/FormSeeder.cs b/api/src/Kurs.Platform.DbMigrator/Seeds/FormSeeder.cs deleted file mode 100644 index 98a7653d..00000000 --- a/api/src/Kurs.Platform.DbMigrator/Seeds/FormSeeder.cs +++ /dev/null @@ -1,347 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Text.Json; -using System.Threading.Tasks; -using Kurs.Languages.Languages; -using Kurs.Platform.Entities; -using Kurs.Platform.Enums; -using Kurs.Platform.ListForms; -using Kurs.Platform.Queries; -using Volo.Abp.Data; -using Volo.Abp.DependencyInjection; -using Volo.Abp.Domain.Repositories; -using static Kurs.Platform.PlatformConsts; -using AppCodes = Kurs.Platform.Data.Seeds.SeedConsts.AppCodes; - -namespace Kurs.Platform.Data.Seeds; - -public class FormSeeder : IDataSeedContributor, ITransientDependency -{ - private readonly IRepository _listFormRepository; - private readonly IRepository _listFormFieldRepository; - - public FormSeeder( - IRepository listFormRepository, - IRepository listFormFieldRepository) - { - _listFormRepository = listFormRepository; - _listFormFieldRepository = listFormFieldRepository; - } - - public async Task SeedAsync(DataSeedContext context) - { - if (await _listFormRepository.AnyAsync(a => a.ListFormCode == ListFormCodes.Forms.FormLanguage)) - { - return; - } - - #region Languages - var formLanguage = await _listFormRepository.InsertAsync( - new ListForm() - { - ListFormType = ListFormTypeEnum.Form, - IsSubForm = false, - SubFormsJson = JsonSerializer.Serialize(new List() { - new { - TabTitle = "Language Texts", - TabType = ListFormTabTypeEnum.List, - Code = ListFormCodes.LanguageText, - Relation = new List() { - new { - ParentFieldName = "CultureName", - ChildFieldName = "CultureName" - } - } - }, - new { - TabTitle = "Form Sütun Sayıları", - TabType = ListFormTabTypeEnum.Chart, - Code = ChartCodes.Chart2, - Relation = new List() { - new { - ParentFieldName = "ListFormCode", - ChildFieldName = "ListFormCode" - } - } - } - }), - CultureName = LanguageCodes.En, - ListFormCode = ListFormCodes.Forms.FormLanguage, - Name = AppCodes.Languages.Language, - Title = AppCodes.Languages.Language, - DataSourceCode = SeedConsts.DataSources.DefaultCode, - IsTenant = false, - IsOrganizationUnit = false, - Description = AppCodes.Languages.Language, - SelectCommandType = SelectCommandTypeEnum.Table, - SelectCommand = DbTablePrefix + "Language", - KeyFieldName = "Id", - KeyFieldDbSourceType = DbType.Guid, - DefaultFilter = "\"IsDeleted\" = 'false'", - SortMode = GridOptions.SortModeSingle, - PermissionJson = JsonSerializer.Serialize(new PermissionCrudDto - { - C = AppCodes.Languages.Language + ".Create", - R = AppCodes.Languages.Language, - U = AppCodes.Languages.Language + ".Update", - D = AppCodes.Languages.Language + ".Delete", - E = AppCodes.Languages.Language + ".Export" - }), - DeleteCommand = $"UPDATE \"{DbTablePrefix}Language\" SET \"DeleterId\"=@DeleterId, \"DeletionTime\"=CURRENT_TIMESTAMP, \"IsDeleted\"='true' WHERE \"Id\"=@Id", - DeleteFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[] { - new() { - FieldName = "DeleterId", - FieldDbType = DbType.Guid, - Value = "@USERID", - CustomValueType = FieldCustomValueTypeEnum.CustomKey }, - new() { - FieldName = "Id", - FieldDbType = DbType.Guid, - Value = "@ID", - CustomValueType = FieldCustomValueTypeEnum.CustomKey } - }), - EditingOptionJson = JsonSerializer.Serialize(new GridEditingDto - { - AllowDeleting = true, - AllowAdding = true, - AllowUpdating = true, - ConfirmDelete = true, - }), - EditingFormJson = JsonSerializer.Serialize(new List() { - new() { - Order = 1, - ColCount = 1, - ColSpan = 2, - ItemType = "group", - Items = [ - new() { Order = 1, DataField = "CultureName", ColSpan = 2, IsRequired = true, EditorType2=EditorTypes.dxTextBox }, - new() { Order = 2, DataField = "UiCultureName", ColSpan = 2, IsRequired = true, EditorType2=EditorTypes.dxTextBox }, - new() { Order = 3, DataField = "DisplayName", ColSpan = 2, IsRequired = true, EditorType2=EditorTypes.dxTextBox }, - new() { Order = 4, DataField = "IsEnabled", ColSpan = 2, IsRequired = false, EditorType2=EditorTypes.dxCheckBox }, - new() { Order = 5, DataField = "MultipleCultures", ColSpan = 2, IsRequired = false, EditorType2=EditorTypes.dxTagBox }, - ] - } - }), - InsertFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[] { - new() { - FieldName = "CreationTime", - FieldDbType = DbType.DateTime, - Value = "@NOW", - CustomValueType = FieldCustomValueTypeEnum.CustomKey }, - new() { - FieldName = "CreatorId", - FieldDbType = DbType.Guid, - Value = "@USERID", - CustomValueType = FieldCustomValueTypeEnum.CustomKey }, - new() { - FieldName = "IsDeleted", - FieldDbType = DbType.Boolean, - Value = "false", - CustomValueType = FieldCustomValueTypeEnum.Value } - }), - FormFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[] { - new() { - FieldName = "IsEnabled", - FieldDbType = DbType.Boolean, - Value = "true", - CustomValueType = FieldCustomValueTypeEnum.Value } - }) - } - ); - await _listFormFieldRepository.InsertManyAsync([ - new() { - ListFormCode = formLanguage.ListFormCode, - RoleId = null, - UserId = null, - CultureName = LanguageCodes.En, - SourceDbType = DbType.Guid, - FieldName = "Id", - Width = 100, - ListOrderNo = 0, - Visible = false, - IsActive = true, - IsDeleted = false, - SortIndex = 0, - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = AppCodes.Languages.Language + ".Create", - R = AppCodes.Languages.Language, - U = AppCodes.Languages.Language + ".Update", - E = true, - Deny = false - }), - }, - new() { - ListFormCode = formLanguage.ListFormCode, - RoleId = null, - UserId = null, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "CultureName", - Width = 150, - ListOrderNo = 1, - Visible = true, - IsActive = true, - IsDeleted = false, - SortIndex = 1, - SortDirection = GridColumnOptions.SortOrderAsc, - AllowSearch = true, - ValidationRuleJson = JsonSerializer.Serialize(new ValidationRuleDto[] { - new() { Type = Enum.GetName(UiColumnValidationRuleTypeEnum.required)} - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = AppCodes.Languages.Language + ".Create", - R = AppCodes.Languages.Language, - U = AppCodes.Languages.Language + ".Update", - E = true, - Deny = false - }), - }, - new() - { - ListFormCode = formLanguage.ListFormCode, - RoleId = null, - UserId = null, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "UiCultureName", - Width = 150, - ListOrderNo = 2, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - ValidationRuleJson = JsonSerializer.Serialize(new ValidationRuleDto[] { - new() { Type = Enum.GetName(UiColumnValidationRuleTypeEnum.required)} - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = AppCodes.Languages.Language + ".Create", - R = AppCodes.Languages.Language, - U = AppCodes.Languages.Language + ".Update", - E = true, - Deny = false - }), - }, - new() - { - ListFormCode = formLanguage.ListFormCode, - RoleId = null, - UserId = null, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "DisplayName", - Width = 150, - ListOrderNo = 3, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - ValidationRuleJson = JsonSerializer.Serialize(new ValidationRuleDto[] { - new() { Type = Enum.GetName(UiColumnValidationRuleTypeEnum.required)} - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = AppCodes.Languages.Language + ".Create", - R = AppCodes.Languages.Language, - U = AppCodes.Languages.Language + ".Update", - E = true, - Deny = false - }), - }, - new() - { - ListFormCode = formLanguage.ListFormCode, - RoleId = null, - UserId = null, - CultureName = LanguageCodes.En, - SourceDbType = DbType.Boolean, - FieldName = "IsEnabled", - Width = 125, - ListOrderNo = 4, - Visible = true, - IsActive = true, - IsDeleted = false, - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = AppCodes.Languages.Language + ".Create", - R = AppCodes.Languages.Language, - U = AppCodes.Languages.Language + ".Update", - E = true, - Deny = false - }), - }, - new() - { - ListFormCode = formLanguage.ListFormCode, - RoleId = null, - UserId = null, - CultureName = LanguageCodes.En, - SourceDbType = DbType.DateTime, - FieldName = "CreationTime", - Width = 125, - ListOrderNo = 5, - Visible = true, - IsActive = true, - IsDeleted = false, - ValidationRuleJson = JsonSerializer.Serialize(new ValidationRuleDto[] { - new() { Type = Enum.GetName(UiColumnValidationRuleTypeEnum.required)} - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = AppCodes.Languages.Language + ".Create", - R = AppCodes.Languages.Language, - U = AppCodes.Languages.Language + ".Update", - E = true, - Deny = false - }), - }, - new() - { - ListFormCode = formLanguage.ListFormCode, - RoleId = null, - UserId = null, - CultureName = LanguageCodes.En, - SourceDbType = DbType.String, - FieldName = "MultipleCultures", - Width = 250, - ListOrderNo = 6, - Visible = true, - IsActive = true, - IsDeleted = false, - AllowSearch = true, - ColumnFilterJson = JsonSerializer.Serialize(new ColumnFilterDto - { - AllowFiltering = true - }), - LookupJson = JsonSerializer.Serialize(new LookupDto - { - DataSourceType = UiLookupDataSourceTypeEnum.Query, - DisplayExpr = "Name", - ValueExpr = "Key", - LookupQuery = $"SELECT \"CultureName\" AS \"Key\", \"DisplayName\" AS \"Name\", \"CreationTime\" FROM \"{DbTablePrefix}Language\" WHERE \"IsEnabled\" = 'true' and \"IsDeleted\" = 'false'" - - //TODO: Tasi grid editingform - // EditorTemplateTagBox = new EditorTagBoxDto() - // { - // ApplyValueMode = "useButtons", - // SearchEnabled = true, - // MaxDisplayedTags = 3 - // } - }), - PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto - { - C = AppCodes.Languages.Language + ".Create", - R = AppCodes.Languages.Language, - U = AppCodes.Languages.Language + ".Update", - E = true, - Deny = false - }), - }, - ]); - - #endregion - } -} diff --git a/api/src/Kurs.Platform.DbMigrator/Seeds/ListFormsSeeder.cs b/api/src/Kurs.Platform.DbMigrator/Seeds/ListFormsSeeder.cs index 4d3305a1..c557fa24 100644 --- a/api/src/Kurs.Platform.DbMigrator/Seeds/ListFormsSeeder.cs +++ b/api/src/Kurs.Platform.DbMigrator/Seeds/ListFormsSeeder.cs @@ -65,6 +65,316 @@ public class ListFormsSeeder : IDataSeedContributor, ITransientDependency roleId = userRole.Result.Name.ToString(); } + #region Form + #region Languages + var formLanguage = await _listFormRepository.InsertAsync( + new ListForm() + { + ListFormType = ListFormTypeEnum.Form, + IsSubForm = false, + SubFormsJson = JsonSerializer.Serialize(new List() { + new { + TabTitle = "Language Texts", + TabType = ListFormTabTypeEnum.List, + Code = ListFormCodes.LanguageText, + Relation = new List() { + new { + ParentFieldName = "CultureName", + ChildFieldName = "CultureName" + } + } + }, + new { + TabTitle = "Form Sütun Sayıları", + TabType = ListFormTabTypeEnum.Chart, + Code = ChartCodes.Chart2, + Relation = new List() { + new { + ParentFieldName = "ListFormCode", + ChildFieldName = "ListFormCode" + } + } + } + }), + CultureName = LanguageCodes.En, + ListFormCode = ListFormCodes.Forms.FormLanguage, + Name = AppCodes.Languages.Language, + Title = AppCodes.Languages.Language, + DataSourceCode = SeedConsts.DataSources.DefaultCode, + IsTenant = false, + IsOrganizationUnit = false, + Description = AppCodes.Languages.Language, + SelectCommandType = SelectCommandTypeEnum.Table, + SelectCommand = DbTablePrefix + "Language", + KeyFieldName = "Id", + KeyFieldDbSourceType = DbType.Guid, + DefaultFilter = "\"IsDeleted\" = 'false'", + SortMode = GridOptions.SortModeSingle, + PermissionJson = JsonSerializer.Serialize(new PermissionCrudDto + { + C = AppCodes.Languages.Language + ".Create", + R = AppCodes.Languages.Language, + U = AppCodes.Languages.Language + ".Update", + D = AppCodes.Languages.Language + ".Delete", + E = AppCodes.Languages.Language + ".Export" + }), + DeleteCommand = $"UPDATE \"{DbTablePrefix}Language\" SET \"DeleterId\"=@DeleterId, \"DeletionTime\"=CURRENT_TIMESTAMP, \"IsDeleted\"='true' WHERE \"Id\"=@Id", + DeleteFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[] { + new() { + FieldName = "DeleterId", + FieldDbType = DbType.Guid, + Value = "@USERID", + CustomValueType = FieldCustomValueTypeEnum.CustomKey }, + new() { + FieldName = "Id", + FieldDbType = DbType.Guid, + Value = "@ID", + CustomValueType = FieldCustomValueTypeEnum.CustomKey } + }), + EditingOptionJson = JsonSerializer.Serialize(new GridEditingDto + { + AllowDeleting = true, + AllowAdding = true, + AllowUpdating = true, + ConfirmDelete = true, + }), + EditingFormJson = JsonSerializer.Serialize(new List() { + new() { + Order = 1, + ColCount = 1, + ColSpan = 2, + ItemType = "group", + Items = [ + new() { Order = 1, DataField = "CultureName", ColSpan = 2, IsRequired = true, EditorType2=EditorTypes.dxTextBox }, + new() { Order = 2, DataField = "UiCultureName", ColSpan = 2, IsRequired = true, EditorType2=EditorTypes.dxTextBox }, + new() { Order = 3, DataField = "DisplayName", ColSpan = 2, IsRequired = true, EditorType2=EditorTypes.dxTextBox }, + new() { Order = 4, DataField = "IsEnabled", ColSpan = 2, IsRequired = false, EditorType2=EditorTypes.dxCheckBox }, + new() { Order = 5, DataField = "MultipleCultures", ColSpan = 2, IsRequired = false, EditorType2=EditorTypes.dxTagBox }, + ] + } + }), + InsertFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[] { + new() { + FieldName = "CreationTime", + FieldDbType = DbType.DateTime, + Value = "@NOW", + CustomValueType = FieldCustomValueTypeEnum.CustomKey }, + new() { + FieldName = "CreatorId", + FieldDbType = DbType.Guid, + Value = "@USERID", + CustomValueType = FieldCustomValueTypeEnum.CustomKey }, + new() { + FieldName = "IsDeleted", + FieldDbType = DbType.Boolean, + Value = "false", + CustomValueType = FieldCustomValueTypeEnum.Value } + }), + FormFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[] { + new() { + FieldName = "IsEnabled", + FieldDbType = DbType.Boolean, + Value = "true", + CustomValueType = FieldCustomValueTypeEnum.Value } + }) + } + ); + await _listFormFieldRepository.InsertManyAsync([ + new() { + ListFormCode = formLanguage.ListFormCode, + RoleId = null, + UserId = null, + CultureName = LanguageCodes.En, + SourceDbType = DbType.Guid, + FieldName = "Id", + Width = 100, + ListOrderNo = 0, + Visible = false, + IsActive = true, + IsDeleted = false, + SortIndex = 0, + PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto + { + C = AppCodes.Languages.Language + ".Create", + R = AppCodes.Languages.Language, + U = AppCodes.Languages.Language + ".Update", + E = true, + Deny = false + }), + }, + new() { + ListFormCode = formLanguage.ListFormCode, + RoleId = null, + UserId = null, + CultureName = LanguageCodes.En, + SourceDbType = DbType.String, + FieldName = "CultureName", + Width = 150, + ListOrderNo = 1, + Visible = true, + IsActive = true, + IsDeleted = false, + SortIndex = 1, + SortDirection = GridColumnOptions.SortOrderAsc, + AllowSearch = true, + ValidationRuleJson = JsonSerializer.Serialize(new ValidationRuleDto[] { + new() { Type = Enum.GetName(UiColumnValidationRuleTypeEnum.required)} + }), + PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto + { + C = AppCodes.Languages.Language + ".Create", + R = AppCodes.Languages.Language, + U = AppCodes.Languages.Language + ".Update", + E = true, + Deny = false + }), + }, + new() + { + ListFormCode = formLanguage.ListFormCode, + RoleId = null, + UserId = null, + CultureName = LanguageCodes.En, + SourceDbType = DbType.String, + FieldName = "UiCultureName", + Width = 150, + ListOrderNo = 2, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + ValidationRuleJson = JsonSerializer.Serialize(new ValidationRuleDto[] { + new() { Type = Enum.GetName(UiColumnValidationRuleTypeEnum.required)} + }), + PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto + { + C = AppCodes.Languages.Language + ".Create", + R = AppCodes.Languages.Language, + U = AppCodes.Languages.Language + ".Update", + E = true, + Deny = false + }), + }, + new() + { + ListFormCode = formLanguage.ListFormCode, + RoleId = null, + UserId = null, + CultureName = LanguageCodes.En, + SourceDbType = DbType.String, + FieldName = "DisplayName", + Width = 150, + ListOrderNo = 3, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + ValidationRuleJson = JsonSerializer.Serialize(new ValidationRuleDto[] { + new() { Type = Enum.GetName(UiColumnValidationRuleTypeEnum.required)} + }), + PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto + { + C = AppCodes.Languages.Language + ".Create", + R = AppCodes.Languages.Language, + U = AppCodes.Languages.Language + ".Update", + E = true, + Deny = false + }), + }, + new() + { + ListFormCode = formLanguage.ListFormCode, + RoleId = null, + UserId = null, + CultureName = LanguageCodes.En, + SourceDbType = DbType.Boolean, + FieldName = "IsEnabled", + Width = 125, + ListOrderNo = 4, + Visible = true, + IsActive = true, + IsDeleted = false, + PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto + { + C = AppCodes.Languages.Language + ".Create", + R = AppCodes.Languages.Language, + U = AppCodes.Languages.Language + ".Update", + E = true, + Deny = false + }), + }, + new() + { + ListFormCode = formLanguage.ListFormCode, + RoleId = null, + UserId = null, + CultureName = LanguageCodes.En, + SourceDbType = DbType.DateTime, + FieldName = "CreationTime", + Width = 125, + ListOrderNo = 5, + Visible = true, + IsActive = true, + IsDeleted = false, + ValidationRuleJson = JsonSerializer.Serialize(new ValidationRuleDto[] { + new() { Type = Enum.GetName(UiColumnValidationRuleTypeEnum.required)} + }), + PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto + { + C = AppCodes.Languages.Language + ".Create", + R = AppCodes.Languages.Language, + U = AppCodes.Languages.Language + ".Update", + E = true, + Deny = false + }), + }, + new() + { + ListFormCode = formLanguage.ListFormCode, + RoleId = null, + UserId = null, + CultureName = LanguageCodes.En, + SourceDbType = DbType.String, + FieldName = "MultipleCultures", + Width = 250, + ListOrderNo = 6, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + ColumnFilterJson = JsonSerializer.Serialize(new ColumnFilterDto + { + AllowFiltering = true + }), + LookupJson = JsonSerializer.Serialize(new LookupDto + { + DataSourceType = UiLookupDataSourceTypeEnum.Query, + DisplayExpr = "Name", + ValueExpr = "Key", + LookupQuery = $"SELECT \"CultureName\" AS \"Key\", \"DisplayName\" AS \"Name\", \"CreationTime\" FROM \"{DbTablePrefix}Language\" WHERE \"IsEnabled\" = 'true' and \"IsDeleted\" = 'false'" + + //TODO: Tasi grid editingform + // EditorTemplateTagBox = new EditorTagBoxDto() + // { + // ApplyValueMode = "useButtons", + // SearchEnabled = true, + // MaxDisplayedTags = 3 + // } + }), + PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto + { + C = AppCodes.Languages.Language + ".Create", + R = AppCodes.Languages.Language, + U = AppCodes.Languages.Language + ".Update", + E = true, + Deny = false + }), + }, + ]); + #endregion + #endregion + + #region List #region Tenants var listFormTenants = await _listFormRepository.InsertAsync( new ListForm() @@ -8204,5 +8514,371 @@ public class ListFormsSeeder : IDataSeedContributor, ITransientDependency ]); #endregion #endregion + + #region ClaimTypes + var listFormClaimTypes = await _listFormRepository.InsertAsync( + new ListForm() + { + CultureName = LanguageCodes.En, + ListFormCode = ListFormCodes.ClaimTypes, + Name = AppCodes.IdentityPermissions.Users.ClaimTypes, + Title = AppCodes.IdentityPermissions.Users.ClaimTypes, + DataSourceCode = SeedConsts.DataSources.DefaultCode, + IsTenant = false, + IsOrganizationUnit = false, + Description = AppCodes.IdentityPermissions.Users.ClaimTypes, + SelectCommandType = SelectCommandTypeEnum.Table, + SelectCommand = "AbpClaimTypes", + KeyFieldName = "Id", + KeyFieldDbSourceType = DbType.Guid, + SortMode = GridOptions.SortModeSingle, + FilterRowJson = JsonSerializer.Serialize(new GridFilterRowDto + { + Visible = true + }), + HeaderFilterJson = JsonSerializer.Serialize(new + { + Visible = true + }), + SearchPanelJson = JsonSerializer.Serialize(new + { + Visible = true + }), + GroupPanelJson = JsonSerializer.Serialize(new + { + Visible = true + }), + SelectionJson = JsonSerializer.Serialize(new SelectionDto + { + Mode = GridOptions.SelectionModeSingle, + AllowSelectAll = false + }), + ColumnOptionJson = JsonSerializer.Serialize(new + { + ColumnFixingEnabled = true, + ColumnChooserEnabled = true + }), + PermissionJson = JsonSerializer.Serialize(new PermissionCrudDto + { + C = AppCodes.IdentityPermissions.Users.ClaimTypes + ".Create", + R = AppCodes.IdentityPermissions.Users.ClaimTypes, + U = AppCodes.IdentityPermissions.Users.ClaimTypes + ".Update", + D = AppCodes.IdentityPermissions.Users.ClaimTypes + ".Delete", + E = AppCodes.IdentityPermissions.Users.ClaimTypes + ".Export" + }), + PagerOptionJson = JsonSerializer.Serialize(new GridPagerOptionDto + { + Visible = true, + AllowedPageSizes = "10,20,50,100", + ShowPageSizeSelector = true, + ShowNavigationButtons = true, + ShowInfo = false, + InfoText = "Page {0} of {1} ({2} items)", + DisplayMode = GridColumnOptions.PagerDisplayModeAdaptive, + ScrollingMode = GridColumnOptions.ScrollingModeStandard, + LoadPanelEnabled = "auto", + LoadPanelText = "Loading..." + }), + EditingOptionJson = JsonSerializer.Serialize(new GridEditingDto + { + Popup = new GridEditingPopupDto() + { + Title = "Claim Types Form", + Width = 500, + Height = 550 + }, + AllowDeleting = true, + AllowAdding = true, + AllowUpdating = true, + SendOnlyChangedFormValuesUpdate = false, + }), + EditingFormJson = JsonSerializer.Serialize(new List() + { + new() { Order=1, ColCount=1, ColSpan=2, ItemType="group", Items = + [ + new EditingFormItemDto { Order=1, DataField="Name", ColSpan=2, IsRequired=true, EditorType2=EditorTypes.dxTextBox, EditorOptions="{ \"showClearButton\" : true }" }, + new EditingFormItemDto { Order=2, DataField="ValueType", ColSpan=2, IsRequired=true, EditorType2=EditorTypes.dxSelectBox }, + new EditingFormItemDto { Order=3, DataField="Required", ColSpan=2, IsRequired=false, EditorType2=EditorTypes.dxCheckBox }, + new EditingFormItemDto { Order=4, DataField="IsStatic", ColSpan=2, IsRequired=false, EditorType2=EditorTypes.dxCheckBox }, + new EditingFormItemDto { Order=5, DataField="Regex", ColSpan=2, IsRequired=false, EditorType2=EditorTypes.dxTextBox, EditorOptions="{ \"showClearButton\" : true }" }, + new EditingFormItemDto { Order=6, DataField="RegexDescription", ColSpan=2, IsRequired=false, EditorType2=EditorTypes.dxTextBox, EditorOptions="{ \"showClearButton\" : true }" }, + new EditingFormItemDto { Order=7, DataField="Description", ColSpan=2, IsRequired=false, EditorType2=EditorTypes.dxTextBox, EditorOptions="{ \"showClearButton\" : true }" }, + ] + } + }), + DeleteCommand = "DELETE FROM \"AbpClaimTypes\" WHERE \"Id\"=@Id", + DeleteFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[] { + new() { + FieldName = "Id", + FieldDbType = DbType.Guid, + Value = "@ID", + CustomValueType = FieldCustomValueTypeEnum.CustomKey } + }), + InsertCommand = "INSERT INTO \"AbpClaimTypes\" (\"Id\",\"ValueType\",\"Required\",\"IsStatic\",\"Name\",\"ConcurrencyStamp\",\"ExtraProperties\") OUTPUT Inserted.Id VALUES (@Id,@ValueType,@Required,@IsStatic,@Name,@ConcurrencyStamp,@ExtraProperties)", + InsertFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[] { + new() { + FieldName = "ConcurrencyStamp", + FieldDbType = DbType.Guid, + Value = Guid.NewGuid().ToString(), + CustomValueType = FieldCustomValueTypeEnum.Value }, + new() { + FieldName = "ExtraProperties", + FieldDbType = DbType.String, + Value = "{}", + CustomValueType = FieldCustomValueTypeEnum.Value } + }), + FormFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[] { + new() { + FieldName = "Required", + FieldDbType = DbType.Boolean, + Value = "false", + CustomValueType = FieldCustomValueTypeEnum.Value }, + new() { + FieldName = "IsStatic", + FieldDbType = DbType.Boolean, + Value = "false", + CustomValueType = FieldCustomValueTypeEnum.Value }, + new() { + FieldName = "ValueType", + FieldDbType = DbType.Int16, + Value = "0", + CustomValueType = FieldCustomValueTypeEnum.Value } + }) + + } + ); + + #region ClaimTypes Fields + await _listFormFieldRepository.InsertManyAsync( + [ + new ListFormField + { + ListFormCode = listFormClaimTypes.ListFormCode, + RoleId = null, + UserId = null, + CultureName = LanguageCodes.En, + SourceDbType = DbType.Guid, + FieldName = "Id", + Width = 500, + ListOrderNo = 0, + Visible = false, + IsActive = true, + IsDeleted = false, + PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto + { + C = AppCodes.IdentityPermissions.Users.ClaimTypes + ".Create", + R = AppCodes.IdentityPermissions.Users.ClaimTypes, + U = AppCodes.IdentityPermissions.Users.ClaimTypes + ".Update", + E = true, + Deny = false + }), + PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto + { + IsPivot = true + }) + }, + new ListFormField + { + ListFormCode = listFormClaimTypes.ListFormCode, + RoleId = null, + UserId = null, + CultureName = LanguageCodes.En, + SourceDbType = DbType.String, + FieldName = "Name", + Width = 200, + ListOrderNo = 1, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto + { + C = AppCodes.IdentityPermissions.Users.ClaimTypes + ".Create", + R = AppCodes.IdentityPermissions.Users.ClaimTypes, + U = AppCodes.IdentityPermissions.Users.ClaimTypes + ".Update", + E = true, + Deny = false + }), + PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto + { + IsPivot = true + }) + }, + new ListFormField + { + ListFormCode = listFormClaimTypes.ListFormCode, + RoleId = null, + UserId = null, + CultureName = LanguageCodes.En, + SourceDbType = DbType.Int16, + FieldName = "ValueType", + Width = 100, + ListOrderNo = 2, + Visible = true, + IsActive = true, + IsDeleted = false, + LookupJson = JsonSerializer.Serialize(new LookupDto + { + + DataSourceType = UiLookupDataSourceTypeEnum.StaticData, + DisplayExpr = "name", + ValueExpr = "key", + LookupQuery = JsonSerializer.Serialize(new LookupDataDto[] { + new () { Key=0,Name="String" }, + new () { Key=1,Name="Number" }, + new () { Key=2,Name="Boolean" }, + new () { Key=3,Name="DateTime" }, + }), + }), + PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto + { + C = AppCodes.IdentityPermissions.Users.ClaimTypes + ".Create", + R = AppCodes.IdentityPermissions.Users.ClaimTypes, + U = AppCodes.IdentityPermissions.Users.ClaimTypes + ".Update", + E = true, + Deny = false + }), + PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto + { + IsPivot = true + }) + }, + new ListFormField + { + ListFormCode = listFormClaimTypes.ListFormCode, + RoleId = null, + UserId = null, + CultureName = LanguageCodes.En, + SourceDbType = DbType.Boolean, + FieldName = "Required", + Width = 100, + ListOrderNo = 3, + Visible = true, + IsActive = true, + IsDeleted = false, + PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto + { + C = AppCodes.IdentityPermissions.Users.ClaimTypes + ".Create", + R = AppCodes.IdentityPermissions.Users.ClaimTypes, + U = AppCodes.IdentityPermissions.Users.ClaimTypes + ".Update", + E = true, + Deny = false + }), + PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto + { + IsPivot = true + }) + }, + new ListFormField + { + ListFormCode = listFormClaimTypes.ListFormCode, + RoleId = null, + UserId = null, + CultureName = LanguageCodes.En, + SourceDbType = DbType.Boolean, + FieldName = "IsStatic", + Width = 100, + ListOrderNo = 4, + Visible = true, + IsActive = true, + IsDeleted = false, + PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto + { + C = AppCodes.IdentityPermissions.Users.ClaimTypes + ".Create", + R = AppCodes.IdentityPermissions.Users.ClaimTypes, + U = AppCodes.IdentityPermissions.Users.ClaimTypes + ".Update", + E = true, + Deny = false + }), + PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto + { + IsPivot = true + }) + }, + new ListFormField + { + ListFormCode = listFormClaimTypes.ListFormCode, + RoleId = null, + UserId = null, + CultureName = LanguageCodes.En, + SourceDbType = DbType.String, + FieldName = "Regex", + Width = 250, + ListOrderNo = 5, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto + { + C = AppCodes.IdentityPermissions.Users.ClaimTypes + ".Create", + R = AppCodes.IdentityPermissions.Users.ClaimTypes, + U = AppCodes.IdentityPermissions.Users.ClaimTypes + ".Update", + E = true, + Deny = false + }), + PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto + { + IsPivot = true + }) + }, + new ListFormField + { + ListFormCode = listFormClaimTypes.ListFormCode, + RoleId = null, + UserId = null, + CultureName = LanguageCodes.En, + SourceDbType = DbType.String, + FieldName = "RegexDescription", + Width = 250, + ListOrderNo = 6, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto + { + C = AppCodes.IdentityPermissions.Users.ClaimTypes + ".Create", + R = AppCodes.IdentityPermissions.Users.ClaimTypes, + U = AppCodes.IdentityPermissions.Users.ClaimTypes + ".Update", + E = true, + Deny = false + }), + PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto + { + IsPivot = true + }) + }, + new ListFormField + { + ListFormCode = listFormClaimTypes.ListFormCode, + RoleId = null, + UserId = null, + CultureName = LanguageCodes.En, + SourceDbType = DbType.String, + FieldName = "Description", + Width = 250, + ListOrderNo = 7, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto + { + C = AppCodes.IdentityPermissions.Users.ClaimTypes + ".Create", + R = AppCodes.IdentityPermissions.Users.ClaimTypes, + U = AppCodes.IdentityPermissions.Users.ClaimTypes + ".Update", + E = true, + Deny = false + }), + PivotSettingsJson = JsonSerializer.Serialize(new ListFormFieldPivotSettingsDto + { + IsPivot = true + }) + } + ]); + #endregion + #endregion + #endregion } } diff --git a/api/src/Kurs.Platform.DbMigrator/Seeds/SeederData.json b/api/src/Kurs.Platform.DbMigrator/Seeds/SeederData.json index c78c029b..d9c2ef30 100644 --- a/api/src/Kurs.Platform.DbMigrator/Seeds/SeederData.json +++ b/api/src/Kurs.Platform.DbMigrator/Seeds/SeederData.json @@ -612,6 +612,12 @@ "en": "Administration", "tr": "Yönetim" }, + { + "resourceName": "Platform", + "key": "AbpIdentity.Users.ClaimType", + "en": "Claim Types", + "tr": "Talep Tipleri" + }, { "resourceName": "Platform", "key": "AbpIdentity.Users.SecurityLog", @@ -645,8 +651,8 @@ { "resourceName": "Platform", "key": "AbpTenantManagement", - "en": "Tenant Management", - "tr": "Tenant Management" + "en": "Tenants", + "tr": "Tenants" }, { "resourceName": "Platform", @@ -2001,8 +2007,8 @@ { "resourceName": "Platform", "key": "Abp.Identity.User.LockoutManagement.LoginAndLockoutSettings", - "en": "Login And Lockout Settings", - "tr": "Giriş ve Kilit Ayarları" + "en": "Lockout Settings", + "tr": "Kilit Ayarları" }, { "resourceName": "Platform", @@ -2046,6 +2052,30 @@ "en": "Update Time", "tr": "Güncelleme Tarihi" }, + { + "resourceName": "Platform", + "key": "Abp.Identity.User.ClaimTypes", + "en": "Claim Types", + "tr": "Talep Tipleri" + }, + { + "resourceName": "Platform", + "key": "Abp.Identity.User.ClaimType", + "en": "ClaimType", + "tr": "Talep Tipi" + }, + { + "resourceName": "Platform", + "key": "Abp.Identity.User.NoClaimsFound", + "en": "No Claims Found", + "tr": "Talep Bulunamadı" + }, + { + "resourceName": "Platform", + "key": "Abp.Identity.User.ClaimValue", + "en": "ClaimValue", + "tr": "Talep Değeri" + }, { "resourceName": "Platform", "key": "Abp.Identity.User.LockoutManagement", @@ -5899,7 +5929,7 @@ "ParentCode": null, "Code": "App.Platform", "DisplayName": "App.Platform", - "Order": -1, + "Order": 100, "Url": null, "Icon": "FcTabletAndroid", "RequiredPermissionName": null, @@ -5909,47 +5939,17 @@ "ParentCode": null, "Code": "App.Home", "DisplayName": "App.Home", - "Order": 0, + "Order": 200, "Url": "/", "Icon": "FcHome", "RequiredPermissionName": null, "IsDisabled": false }, - { - "ParentCode": null, - "Code": "App.Setting", - "DisplayName": "App.Setting", - "Order": 1, - "Url": "/settings", - "Icon": "FcSettings", - "RequiredPermissionName": "App.Setting", - "IsDisabled": false - }, - { - "ParentCode": "App.Setting", - "Code": "App.Settings.SettingDefinitions", - "DisplayName": "App.Settings.SettingDefinitions", - "Order": 1, - "Url": "/list/List-0009", - "Icon": "FcSupport", - "RequiredPermissionName": "App.Settings.SettingDefinitions", - "IsDisabled": false - }, - { - "ParentCode": "App.Setting", - "Code": "App.Settings.GlobalSearch", - "DisplayName": "App.Settings.GlobalSearch", - "Order": 2, - "Url": "/list/List-0018", - "Icon": "FcSearch", - "RequiredPermissionName": "App.Settings.GlobalSearch", - "IsDisabled": false - }, { "ParentCode": null, "Code": "App.Saas", "DisplayName": "App.Saas", - "Order": 2, + "Order": 300, "Url": null, "Icon": "FcPodiumWithAudience", "RequiredPermissionName": null, @@ -5976,30 +5976,40 @@ "IsDisabled": false }, { - "ParentCode": null, - "Code": "App.Administration", - "DisplayName": "App.Administration", - "Order": 3, - "Url": null, - "Icon": "FcOrganization", - "RequiredPermissionName": null, - "IsDisabled": false - }, - { - "ParentCode": "App.Administration", + "ParentCode": "App.Saas", "Code": "App.Settings", "DisplayName": "App.Settings", - "Order": 0, + "Order": 3, "Url": null, "Icon": "FcCircuit", "RequiredPermissionName": null, "IsDisabled": false }, { - "ParentCode": "App.Administration", + "ParentCode": "App.Settings", + "Code": "App.Settings.SettingDefinitions", + "DisplayName": "App.Settings.SettingDefinitions", + "Order": 1, + "Url": "/list/List-0009", + "Icon": "FcSupport", + "RequiredPermissionName": "App.Settings.SettingDefinitions", + "IsDisabled": false + }, + { + "ParentCode": "App.Settings", + "Code": "App.Settings.GlobalSearch", + "DisplayName": "App.Settings.GlobalSearch", + "Order": 2, + "Url": "/list/List-0018", + "Icon": "FcSearch", + "RequiredPermissionName": "App.Settings.GlobalSearch", + "IsDisabled": false + }, + { + "ParentCode": "App.Saas", "Code": "App.Languages", "DisplayName": "App.Languages", - "Order": 1, + "Order": 4, "Url": null, "Icon": "FcGlobe", "RequiredPermissionName": null, @@ -6025,6 +6035,36 @@ "RequiredPermissionName": "App.Languages.LanguageText", "IsDisabled": false }, + { + "ParentCode": "App.Saas", + "Code": "App.Menus", + "DisplayName": "App.Menus", + "Order": 5, + "Url": "/list/List-0007", + "Icon": "FcMenu", + "RequiredPermissionName": "App.Menus", + "IsDisabled": false + }, + { + "ParentCode": null, + "Code": "App.Administration", + "DisplayName": "App.Administration", + "Order": 400, + "Url": null, + "Icon": "FcOrganization", + "RequiredPermissionName": null, + "IsDisabled": false + }, + { + "ParentCode": "App.Administration", + "Code": "App.Setting", + "DisplayName": "App.Setting", + "Order": 1, + "Url": "/settings", + "Icon": "FcSettings", + "RequiredPermissionName": "App.Setting", + "IsDisabled": false + }, { "ParentCode": "App.Administration", "Code": "Abp.Identity", @@ -6039,7 +6079,7 @@ "ParentCode": "Abp.Identity", "Code": "Abp.Identity.PermissionGroups", "DisplayName": "Abp.Identity.PermissionGroups", - "Order": 0, + "Order": 1, "Url": "/list/List-0017", "Icon": "FcEngineering", "RequiredPermissionName": "Abp.Identity.PermissionGroups", @@ -6049,7 +6089,7 @@ "ParentCode": "Abp.Identity", "Code": "Abp.Identity.Permissions", "DisplayName": "Abp.Identity.Permissions", - "Order": 1, + "Order": 2, "Url": "/list/List-0002", "Icon": "FcSupport", "RequiredPermissionName": "Abp.Identity.Permissions", @@ -6059,7 +6099,7 @@ "ParentCode": "Abp.Identity", "Code": "AbpIdentity.Roles", "DisplayName": "AbpIdentity.Roles", - "Order": 2, + "Order": 3, "Url": "/list/List-0003", "Icon": "FcFlowChart", "RequiredPermissionName": "AbpIdentity.Roles", @@ -6069,57 +6109,57 @@ "ParentCode": "Abp.Identity", "Code": "AbpIdentity.Users", "DisplayName": "AbpIdentity.Users", - "Order": 3, + "Order": 4, "Url": "/list/List-0004", "Icon": "FcBusinessman", "RequiredPermissionName": "AbpIdentity.Users", "IsDisabled": false }, - { - "ParentCode": "AbpIdentity.Users", - "Code": "AbpIdentity.Users.SecurityLog", - "DisplayName": "AbpIdentity.Users.SecurityLog", - "Order": 6, - "Url": "/list/List-0019", - "Icon": "FcPrivacy", - "RequiredPermissionName": "AbpIdentity.Users.SecurityLog", - "IsDisabled": false - }, { "ParentCode": "Abp.Identity", "Code": "Abp.Identity.OrganizationUnits", "DisplayName": "Abp.Identity.OrganizationUnits", - "Order": 4, + "Order": 5, "Url": "/admin/ous", "Icon": "FcOrganization", "RequiredPermissionName": "Abp.Identity.OrganizationUnits", "IsDisabled": false }, + { + "ParentCode": "Abp.Identity", + "Code": "AbpIdentity.Users.ClaimType", + "DisplayName": "AbpIdentity.Users.ClaimType", + "Order": 6, + "Url": "/list/List-0022", + "Icon": "FcOrganization", + "RequiredPermissionName": "AbpIdentity.Users.ClaimType", + "IsDisabled": false + }, { "ParentCode": "Abp.Identity", "Code": "App.IpRestrictions", "DisplayName": "App.IpRestrictions", - "Order": 5, + "Order": 7, "Url": "/list/List-0015", "Icon": "FcNfcSign", "RequiredPermissionName": "App.IpRestrictions", "IsDisabled": false }, { - "ParentCode": "App.Administration", - "Code": "App.Menus", - "DisplayName": "App.Menus", - "Order": 3, - "Url": "/list/List-0007", - "Icon": "FcMenu", - "RequiredPermissionName": "App.Menus", + "ParentCode": "AbpIdentity.Users", + "Code": "AbpIdentity.Users.SecurityLog", + "DisplayName": "AbpIdentity.Users.SecurityLog", + "Order": 8, + "Url": "/list/List-0019", + "Icon": "FcPrivacy", + "RequiredPermissionName": "AbpIdentity.Users.SecurityLog", "IsDisabled": false }, { - "ParentCode": "App.Administration", + "ParentCode": "App.Saas", "Code": "App.Listforms", "DisplayName": "App.Listforms", - "Order": 4, + "Order": 6, "Url": null, "Icon": "FcList", "RequiredPermissionName": null, @@ -6129,7 +6169,7 @@ "ParentCode": "App.Listforms", "Code": "App.Listforms.DataSource", "DisplayName": "App.Listforms.DataSource", - "Order": 0, + "Order": 1, "Url": "/list/List-0011", "Icon": "FcAcceptDatabase", "RequiredPermissionName": "App.Listforms.DataSource", @@ -6139,7 +6179,7 @@ "ParentCode": "App.Listforms", "Code": "App.Listforms.Wizard", "DisplayName": "App.Listforms.Wizard", - "Order": 1, + "Order": 2, "Url": "/admin/listform/wizard", "Icon": "FcFlashAuto", "RequiredPermissionName": "App.Listforms.Wizard", @@ -6149,7 +6189,7 @@ "ParentCode": "App.Listforms", "Code": "App.Listforms.Listform", "DisplayName": "App.Listforms.Listform", - "Order": 2, + "Order": 3, "Url": "/list/List-0008", "Icon": "FcDataSheet", "RequiredPermissionName": "App.Listforms.Listform", @@ -6159,17 +6199,17 @@ "ParentCode": "App.Listforms", "Code": "App.Listforms.Chart", "DisplayName": "App.Listforms.Chart", - "Order": 3, + "Order": 4, "Url": "/list/List-0010", "Icon": "FcTodoList", "RequiredPermissionName": "App.Listforms.Chart", "IsDisabled": false }, { - "ParentCode": "App.Administration", + "ParentCode": "App.Saas", "Code": "App.Notifications", "DisplayName": "App.Notifications", - "Order": 5, + "Order": 7, "Url": null, "Icon": "FcWorkflow", "RequiredPermissionName": null, @@ -6196,20 +6236,20 @@ "IsDisabled": false }, { - "ParentCode": "App.Administration", + "ParentCode": "App.Saas", "Code": "App.BackgroundWorkers", "DisplayName": "App.BackgroundWorkers", - "Order": 6, + "Order": 8, "Url": "/list/List-0012", "Icon": "FcWorkflow", "RequiredPermissionName": "App.BackgroundWorkers", "IsDisabled": false }, { - "ParentCode": "App.Administration", + "ParentCode": "App.Saas", "Code": "App.PublicApis", "DisplayName": "App.PublicApis", - "Order": 7, + "Order": 9, "Url": "/list/List-0016", "Icon": "FcMindMap", "RequiredPermissionName": "App.PublicApis", @@ -6219,7 +6259,7 @@ "ParentCode": "App.Administration", "Code": "App.AuditLogs", "DisplayName": "App.AuditLogs", - "Order": 8, + "Order": 3, "Url": "/list/List-0020", "Icon": "FcMultipleInputs", "RequiredPermissionName": "App.AuditLogs", @@ -6227,61 +6267,61 @@ } ], "PermissionGroupDefinitionRecords": [ + { + "Name": "App.Platform", + "DisplayName": "App.Platform" + }, { "Name": "AbpTenantManagement", "DisplayName": "AbpTenantManagement" }, { - "Name": "AbpIdentity", - "DisplayName": "AbpIdentity" - }, - { - "Name": "App.Platform", - "DisplayName": "App.Platform" - }, - { - "Name": "App.Setting", - "DisplayName": "App.Setting" - }, - { - "Name": "App.Languages", - "DisplayName": "App.Languages" - }, - { - "Name": "App.Listforms", - "DisplayName": "App.Listforms" - }, - { - "Name": "App.Menus", - "DisplayName": "App.Menus" + "Name": "App.Branches", + "DisplayName": "App.Branches" }, { "Name": "App.Settings.SettingDefinitions", "DisplayName": "App.Settings.SettingDefinitions" }, { - "Name": "App.BackgroundWorkers", - "DisplayName": "App.BackgroundWorkers" + "Name": "App.Settings.GlobalSearch", + "DisplayName": "App.Settings.GlobalSearch" + }, + { + "Name": "App.Languages", + "DisplayName": "App.Languages" + }, + { + "Name": "App.Menus", + "DisplayName": "App.Menus" + }, + { + "Name": "App.Listforms", + "DisplayName": "App.Listforms" }, { "Name": "App.Notifications", "DisplayName": "App.Notifications" }, + { + "Name": "App.BackgroundWorkers", + "DisplayName": "App.BackgroundWorkers" + }, { "Name": "App.PublicApis", "DisplayName": "App.PublicApis" }, { - "Name": "App.Settings.GlobalSearch", - "DisplayName": "App.Settings.GlobalSearch" + "Name": "App.Setting", + "DisplayName": "App.Setting" + }, + { + "Name": "AbpIdentity", + "DisplayName": "AbpIdentity" }, { "Name": "App.AuditLogs", "DisplayName": "App.AuditLogs" - }, - { - "Name": "App.Branches", - "DisplayName": "App.Branches" } ], "PermissionDefinitionRecords": [ @@ -6340,6 +6380,14 @@ "DisplayName": "AbpIdentity.Users.SecurityLog", "IsEnabled": true, "MultiTenancySide": 3 + }, + { + "GroupName": "AbpIdentity", + "Name": "AbpIdentity.Users.ClaimType", + "ParentName": null, + "DisplayName": "AbpIdentity.Users.ClaimType", + "IsEnabled": true, + "MultiTenancySide": 3 }, { "GroupName": "AbpIdentity", @@ -6949,6 +6997,38 @@ "IsEnabled": true, "MultiTenancySide": 2 }, + { + "GroupName": "AbpIdentity", + "Name": "AbpIdentity.Users.ClaimType.Create", + "ParentName": "AbpIdentity.Users.ClaimType", + "DisplayName": "Create", + "IsEnabled": true, + "MultiTenancySide": 3 + }, + { + "GroupName": "AbpIdentity", + "Name": "AbpIdentity.Users.ClaimType.Delete", + "ParentName": "AbpIdentity.Users.ClaimType", + "DisplayName": "Delete", + "IsEnabled": true, + "MultiTenancySide": 3 + }, + { + "GroupName": "AbpIdentity", + "Name": "AbpIdentity.Users.ClaimType.Export", + "ParentName": "AbpIdentity.Users.ClaimType", + "DisplayName": "Export", + "IsEnabled": true, + "MultiTenancySide": 3 + }, + { + "GroupName": "AbpIdentity", + "Name": "AbpIdentity.Users.ClaimType.Update", + "ParentName": "AbpIdentity.Users.ClaimType", + "DisplayName": "Update", + "IsEnabled": true, + "MultiTenancySide": 3 + }, { "GroupName": "AbpIdentity", "Name": "App.IpRestrictions.Create", diff --git a/api/src/Kurs.Platform.Domain.Shared/PlatformConsts.cs b/api/src/Kurs.Platform.Domain.Shared/PlatformConsts.cs index 65a0633b..01fac3f9 100644 --- a/api/src/Kurs.Platform.Domain.Shared/PlatformConsts.cs +++ b/api/src/Kurs.Platform.Domain.Shared/PlatformConsts.cs @@ -327,7 +327,8 @@ public static class PlatformConsts public const string GlobalSearch = "List-0018"; public const string SecurityLog = "List-0019"; public const string AuditLog = "List-0020"; - public const string Branch = "List-0022"; + public const string Branch = "List-0021"; + public const string ClaimTypes = "List-0022"; public const string ListformField = "List-1000"; public const string Order = "List-Order"; public const string Complaint = "List-Complaint"; diff --git a/api/src/Kurs.Platform.Domain/Data/SeedConsts.cs b/api/src/Kurs.Platform.Domain/Data/SeedConsts.cs index 3ad6cb8f..d23b2cb6 100644 --- a/api/src/Kurs.Platform.Domain/Data/SeedConsts.cs +++ b/api/src/Kurs.Platform.Domain/Data/SeedConsts.cs @@ -319,6 +319,7 @@ public static class SeedConsts { public const string Default = GroupName + ".Users"; public const string SecurityLogs = Default + ".SecurityLog"; + public const string ClaimTypes = Default + ".ClaimType"; } } diff --git a/api/src/Kurs.Platform.HttpApi.Host/Identity/PlatformUserClaimsPrincipalFactory.cs b/api/src/Kurs.Platform.HttpApi.Host/Identity/PlatformUserClaimsPrincipalFactory.cs index c4e31304..d04b73a7 100644 --- a/api/src/Kurs.Platform.HttpApi.Host/Identity/PlatformUserClaimsPrincipalFactory.cs +++ b/api/src/Kurs.Platform.HttpApi.Host/Identity/PlatformUserClaimsPrincipalFactory.cs @@ -1,15 +1,10 @@ using System; -using System.Net; using System.Security.Claims; using System.Security.Principal; -using System.Text; using System.Threading.Tasks; -using System.Web; -using Amazon.Runtime.Internal.Endpoints.StandardLibrary; using Kurs.Platform.Extensions; using Microsoft.AspNetCore.Identity; using Microsoft.Extensions.Options; -using Microsoft.IdentityModel.Tokens; using Volo.Abp.DependencyInjection; using Volo.Abp.Identity; using Volo.Abp.Security.Claims; diff --git a/ui/src/proxy/admin/identity.service.ts b/ui/src/proxy/admin/identity.service.ts index 9824adc5..8d5b5794 100644 --- a/ui/src/proxy/admin/identity.service.ts +++ b/ui/src/proxy/admin/identity.service.ts @@ -5,6 +5,7 @@ import { IdentityUserDto, PermissionDefinitionRecord, UpdatePermissionsDto, + UserClaimModel, UserInfoViewModel, } from '@/proxy/admin' import apiService from '@/services/api.service' @@ -71,4 +72,17 @@ export const getAuditLogs = (id: string) => apiService.fetchData({ method: 'GET', url: `/api/app/audit-log/${id}`, + }) + +export const postClaimUser = (input: UserClaimModel) => + apiService.fetchData({ + method: 'POST', + url: `/api/app/platform-identity/claim-user`, + data: input, + }) + +export const deleteClaimUser = (id: string, userId?: string) => + apiService.fetchData({ + method: 'DELETE', + url: `/api/app/platform-identity/${id}/claim-user/${userId}`, }) \ No newline at end of file diff --git a/ui/src/proxy/admin/models.ts b/ui/src/proxy/admin/models.ts index 82aea1b0..fc4dab42 100644 --- a/ui/src/proxy/admin/models.ts +++ b/ui/src/proxy/admin/models.ts @@ -123,6 +123,7 @@ export interface UserInfoViewModel extends ExtensibleObject { userRoleNames: string[] roles: AssignedRoleViewModel[] branches: AssignedRoleViewModel[] + claims: AssignedClaimViewModel[] lockUser: boolean lastPasswordChangeTime?: Date | string @@ -143,4 +144,20 @@ export interface AssignedRoleViewModel { export interface AssignedBranchViewModel { name?: string isAssigned: boolean -} \ No newline at end of file +} + +export interface AssignedClaimViewModel +{ + id: string + claimType: string + claimValue: string + isAssigned: boolean +} + +export interface UserClaimModel +{ + id?: string + userId?: string + claimType: string + claimValue: string +} diff --git a/ui/src/views/admin/identity/Users/Details.tsx b/ui/src/views/admin/identity/Users/Details.tsx index 2728864c..22f23772 100644 --- a/ui/src/views/admin/identity/Users/Details.tsx +++ b/ui/src/views/admin/identity/Users/Details.tsx @@ -6,31 +6,56 @@ import { FormItem, Input, Notification, + Select, Tabs, toast, } from '@/components/ui' +import Dialog from '@/components/ui/Dialog' import DateTimepicker from '@/components/ui/DatePicker/DateTimepicker' +import Table from '@/components/ui/Table' +import TBody from '@/components/ui/Table/TBody' +import Td from '@/components/ui/Table/Td' +import Th from '@/components/ui/Table/Th' +import THead from '@/components/ui/Table/THead' +import Tr from '@/components/ui/Table/Tr' import TabContent from '@/components/ui/Tabs/TabContent' import TabList from '@/components/ui/Tabs/TabList' import TabNav from '@/components/ui/Tabs/TabNav' -import { UserInfoViewModel } from '@/proxy/admin' -import { getUserDetail, putUserDetail, putUserLookout } from '@/proxy/admin/identity.service' +import { AssignedClaimViewModel, UserInfoViewModel } from '@/proxy/admin' +import { + deleteClaimUser, + getUserDetail, + postClaimUser, + putUserDetail, + putUserLookout, +} from '@/proxy/admin/identity.service' import { useLocalization } from '@/utils/hooks/useLocalization' import dayjs from 'dayjs' -import { Field, FieldArray, FieldProps, Form, Formik } from 'formik' +import { Field, FieldArray, FieldProps, Form, Formik, FormikHelpers } from 'formik' import { useEffect, useState } from 'react' import { Helmet } from 'react-helmet' -import { HiOutlineLockOpen, HiOutlineUser } from 'react-icons/hi' +import { HiOutlineLockOpen, HiOutlineUser, HiOutlineDocumentAdd } from 'react-icons/hi' +import { MdDelete } from 'react-icons/md' import { useParams } from 'react-router-dom' +import * as Yup from 'yup' +import { SelectBoxOption } from '@/shared/types' +import { ConfirmDialog } from '@/components/shared' + +export interface ClaimTypeDto { + claimType: string + claimValue: string +} function UserDetails() { const { userId } = useParams() const { translate } = useLocalization() const [userDetails, setUserDetails] = useState() + const [loading, setLoading] = useState(true) + const [open, setOpen] = useState(false) + const [confirmDeleteClaim, setConfirmDeleteClaim] = useState(null) const getUser = async () => { const { data } = await getUserDetail(userId || '') - setUserDetails(data) } @@ -38,7 +63,45 @@ function UserDetails() { getUser() }, []) - //translate('::AbpIdentity.Profile'), + const scheme = Yup.object().shape({ + claimType: Yup.string().required(), + claimValue: Yup.string().required(), + }) + + const handleSubmit = async ( + values: ClaimTypeDto, + { setSubmitting }: FormikHelpers, + ) => { + setLoading(true) + setSubmitting(true) + + try { + await postClaimUser({ userId, claimType: values.claimType, claimValue: values.claimValue }) + toast.push( + + {translate('::Kaydet')} + , + { + placement: 'top-center', + }, + ) + setOpen(false) + getUser() + } catch (error) { + toast.push( + + {'Hata'} + , + { + placement: 'top-center', + }, + ) + } finally { + setLoading(false) + setSubmitting(false) + } + } + return userDetails ? ( <> }> - { translate('::Abp.Identity.User.UserInformation') } + {translate('::Abp.Identity.User.UserInformation')} }> - { translate('::Abp.Identity.User.LockoutManagement') } + {translate('::Abp.Identity.User.LockoutManagement')} + + }> + {translate('::Abp.Identity.User.ClaimTypes')} @@ -95,14 +161,23 @@ function UserDetails() { {/* Personal Information */}
- - + +
{/* Şube Management */}
-
{translate('::Abp.Identity.User.UserInformation.BranchManagement')}
+
+ {translate('::Abp.Identity.User.UserInformation.BranchManagement')} +
{({ form, remove, push }) => ( @@ -132,7 +207,9 @@ function UserDetails() { {/* Role Management */}
-
{translate('::Abp.Identity.User.UserInformation.RoleManagement')}
+
+ {translate('::Abp.Identity.User.UserInformation.RoleManagement')} +
{({ form, remove, push }) => ( @@ -162,22 +239,50 @@ function UserDetails() { {/* Contact Information */}
-
{translate('::Abp.Identity.User.UserInformation.ContactInformation')}
- - +
+ {translate('::Abp.Identity.User.UserInformation.ContactInformation')} +
+ + - - + + - +
{/* Account Timestamps */}
-
{translate('::Abp.Identity.User.UserInformation.AccountTimestamps')}
- +
+ {translate('::Abp.Identity.User.UserInformation.AccountTimestamps')} +
+ {({ field, form }: FieldProps) => ( - + {({ field, form }: FieldProps) => ( )} - + {({ field, form }: FieldProps) => ( )} @@ -267,25 +380,37 @@ function UserDetails() {
{/* Account Status */}
-
{translate('::Abp.Identity.User.LockoutManagement.AccountStatus')}
+
+ {translate('::Abp.Identity.User.LockoutManagement.AccountStatus')} +
- + @@ -294,11 +419,15 @@ function UserDetails() { layout="horizontal" labelClass="!justify-start" labelWidth="50%" - label={translate('::Abp.Identity.User.LockoutManagement.EmailConfirmed')} + label={translate( + '::Abp.Identity.User.LockoutManagement.EmailConfirmed', + )} > @@ -307,11 +436,15 @@ function UserDetails() { layout="horizontal" labelClass="!justify-start" labelWidth="50%" - label={translate('::Abp.Identity.User.LockoutManagement.PhoneNumberConfirmed')} + label={translate( + '::Abp.Identity.User.LockoutManagement.PhoneNumberConfirmed', + )} > @@ -320,11 +453,15 @@ function UserDetails() { layout="horizontal" labelClass="!justify-start" labelWidth="50%" - label={translate('::Abp.Identity.User.LockoutManagement.TwoFactorEnabled')} + label={translate( + '::Abp.Identity.User.LockoutManagement.TwoFactorEnabled', + )} > @@ -332,12 +469,18 @@ function UserDetails() { {/* Login & Lockout Settings */}
-
{translate('::Abp.Identity.User.LockoutManagement.LoginAndLockoutSettings')}
+
+ {translate( + '::Abp.Identity.User.LockoutManagement.LoginAndLockoutSettings', + )} +
{({ field, form }: FieldProps) => ( @@ -345,7 +488,9 @@ function UserDetails() { field={field} form={form} value={field.value ? dayjs(field.value).toDate() : null} - placeholder={translate('::Abp.Identity.User.LockoutManagement.LoginEndDate')} + placeholder={translate( + '::Abp.Identity.User.LockoutManagement.LoginEndDate', + )} onChange={(date) => { form.setFieldValue( field.name, @@ -361,11 +506,15 @@ function UserDetails() { layout="horizontal" labelClass="!justify-start" labelWidth="50%" - label={translate('::Abp.Identity.User.LockoutManagement.AccountLockoutEnabled')} + label={translate( + '::Abp.Identity.User.LockoutManagement.AccountLockoutEnabled', + )} > @@ -374,11 +523,15 @@ function UserDetails() { layout="horizontal" labelClass="!justify-start" labelWidth="50%" - label={translate('::Abp.Identity.User.LockoutManagement.AccountLocked')} + label={translate( + '::Abp.Identity.User.LockoutManagement.AccountLocked', + )} > @@ -387,7 +540,9 @@ function UserDetails() { layout="horizontal" labelClass="!justify-start" labelWidth="50%" - label={translate('::Abp.Identity.User.LockoutManagement.AccountEndDate')} + label={translate( + '::Abp.Identity.User.LockoutManagement.AccountEndDate', + )} > {({ field, form }: FieldProps) => ( @@ -395,7 +550,9 @@ function UserDetails() { field={field} form={form} value={field.value ? dayjs(field.value).toDate() : null} - placeholder={translate('::Abp.Identity.User.LockoutManagement.AccountEndDate')} + placeholder={translate( + '::Abp.Identity.User.LockoutManagement.AccountEndDate', + )} onChange={(date) => { form.setFieldValue( field.name, @@ -411,11 +568,15 @@ function UserDetails() { layout="horizontal" labelClass="!justify-start" labelWidth="50%" - label={translate('::Abp.Identity.User.LockoutManagement.ShouldChangePwOnNextLogin')} + label={translate( + '::Abp.Identity.User.LockoutManagement.ShouldChangePwOnNextLogin', + )} > @@ -424,7 +585,9 @@ function UserDetails() { layout="horizontal" labelClass="!justify-start" labelWidth="50%" - label={translate('::Abp.Identity.User.LockoutManagement.AccessFailedCount')} + label={translate( + '::Abp.Identity.User.LockoutManagement.AccessFailedCount', + )} > @@ -444,7 +607,145 @@ function UserDetails() {
+ +
+ + + + + + + + + + {userDetails.claims.filter((a) => a.isAssigned === true) && + userDetails.claims.filter((a) => a.isAssigned === true).length > 0 ? ( + userDetails.claims.map((claim) => ( + + + + + + )) + ) : ( + + + + )} + +
+ {translate('::Abp.Identity.User.ClaimType')}{translate('::Abp.Identity.User.ClaimValue')}
+ {claim.claimType}{claim.claimValue}
+ {translate('::Abp.Identity.User.NoClaimsFound')} +
+
+
+ + setOpen(false)} onRequestClose={() => setOpen(false)}> + + {({ touched, errors, values, isSubmitting }) => { + const claimOptions: SelectBoxOption[] = userDetails?.claims.map((claim) => ({ + value: claim.claimType, + label: claim.claimType, + })) + + return ( +
+ + + + {({ field, form }: FieldProps) => ( +