Browse Source

Merge remote-tracking branch 'origin/dev' into dev

pull/5052/head
maliming 6 years ago
parent
commit
0cbb64adee
  1. 8
      docs/en/CLI.md
  2. 4
      docs/en/UI/Angular/Multi-Tenancy.md
  3. 51
      framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/RequestLocalization/DefaultAbpRequestLocalizationOptionsProvider.cs
  4. 4
      modules/cms-kit/host/Volo.CmsKit.IdentityServer/Pages/Index.cshtml
  5. 5
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/CmsKitWebUnifiedModule.cs
  6. 32
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20200807070949_Reaction_Comment_Multitenancy.cs
  7. 1186
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20200810022644_Initial.Designer.cs
  8. 6
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20200813130355_Initial.Designer.cs
  9. 2
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20200813130355_Initial.cs
  10. 8
      modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Comments/CommentConsts.cs
  11. 9
      modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Entities/CmsEntityConsts.cs
  12. 5
      modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/cs.json
  13. 6
      modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/pl-PL.json
  14. 6
      modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/pt-BR.json
  15. 5
      modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/sl.json
  16. 14
      modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/tr.json
  17. 5
      modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/vi.json
  18. 5
      modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/zh-Hans.json
  19. 5
      modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/zh-Hant.json
  20. 10
      modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Reactions/UserReactionConsts.cs
  21. 7
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/CmsKitOptions.cs
  22. 11
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/Comment.cs
  23. 2
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/CommentWithAuthorQueryResultItem.cs
  24. 5
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/ICommentRepository.cs
  25. 2
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/DefaultReactionDefinitionStore.cs
  26. 9
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/IUserReactionRepository.cs
  27. 1
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Users/CmsUserLookupService.cs
  28. 4
      modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs
  29. 10
      modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContextModelCreatingExtensions.cs
  30. 4
      modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs
  31. 4
      modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/CreateCommentInput.cs
  32. 24
      modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Comments/CommentPublicAppService.cs
  33. 17
      modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Reactions/ReactionPublicAppService.cs
  34. 1
      modules/cms-kit/test/Volo.CmsKit.Application.Tests/Reactions/ReactionPublicAppService_Tests.cs
  35. 8
      modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/en.json
  36. 3
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/appsettings.json
  37. 23
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/IdentityServer/IdentityServerDataSeedContributor.cs
  38. 6
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs
  39. 6
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/MyProjectNameHttpApiHostModule.cs
  40. 6
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs
  41. 6
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebModule.cs
  42. 6
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs

8
docs/en/CLI.md

@ -274,11 +274,13 @@ Then review changes on your source control system to be sure that it has changed
Some features of the CLI requires to be logged in to abp.io platform. To login with your username write: Some features of the CLI requires to be logged in to abp.io platform. To login with your username write:
```bash ```bash
abp login <username> # Asks password separately abp login <username> # Allows you to enter your password hidden
abp login <username> -p <password> # Specify the password as a parameter abp login <username> -p <password> # Specify the password as a parameter (password is visible)
abp login <username> --organization <organization> # If you have multiple organizations, you need set your active organization
abp login <username> -p <password> -o <organization> # You can enter both your password and organization in the same command
``` ```
> Using `-p` parameter might not be safe if someone is watching your screen :) It can be useful for automation purposes. > When using the -p parameter, be careful as your password will be visible. It's useful for CI/CD automation pipelines.
A new login with an already active session overwrites the previous session. A new login with an already active session overwrites the previous session.

4
docs/en/UI/Angular/Multi-Tenancy.md

@ -1,4 +1,4 @@
# Multi Tenancy in Angular UI # Multi Tenancy in Angular UI
ABP Angular UI supports the multi-tenancy. The following features related to multi-tenancy are available in the startup templates. ABP Angular UI supports the multi-tenancy. The following features related to multi-tenancy are available in the startup templates.
@ -17,7 +17,7 @@ On the page above, you can;
![Tenant Switching Component](./images/tenant-switching-box.png) ![Tenant Switching Component](./images/tenant-switching-box.png)
<p style="font-size:small;text-align:center;">Tenant Switching Component</p> <p style="font-size:small;text-align:center;">Tenant Switching Component</p>
You can switch between existing tenants by using the tenant switching component in the child pages of the `AccountLayoutComponent` (like Login page). Angular UI sends the selected tenant id sends to the backend as `__tenant` header on each request. You can switch between existing tenants by using the tenant switching component in the child pages of the `AccountLayoutComponent` (like Login page). Angular UI sends the selected tenant id to the backend as `__tenant` header on each request.
## Domain Tenant Resolver ## Domain Tenant Resolver

51
framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/RequestLocalization/DefaultAbpRequestLocalizationOptionsProvider.cs

@ -50,35 +50,38 @@ namespace Microsoft.AspNetCore.RequestLocalization
{ {
using (await _syncSemaphore.LockAsync()) using (await _syncSemaphore.LockAsync())
{ {
using (var serviceScope = _serviceProviderFactory.CreateScope()) if (_requestLocalizationOptions == null)
{ {
var languageProvider = serviceScope.ServiceProvider.GetRequiredService<ILanguageProvider>(); using (var serviceScope = _serviceProviderFactory.CreateScope())
var settingProvider = serviceScope.ServiceProvider.GetRequiredService<ISettingProvider>(); {
var languageProvider = serviceScope.ServiceProvider.GetRequiredService<ILanguageProvider>();
var settingProvider = serviceScope.ServiceProvider.GetRequiredService<ISettingProvider>();
var languages = await languageProvider.GetLanguagesAsync(); var languages = await languageProvider.GetLanguagesAsync();
var defaultLanguage = await settingProvider.GetOrNullAsync(LocalizationSettingNames.DefaultLanguage); var defaultLanguage = await settingProvider.GetOrNullAsync(LocalizationSettingNames.DefaultLanguage);
var options = !languages.Any() var options = !languages.Any()
? new RequestLocalizationOptions() ? new RequestLocalizationOptions()
: new RequestLocalizationOptions : new RequestLocalizationOptions
{ {
DefaultRequestCulture = DefaultGetRequestCulture(defaultLanguage, languages), DefaultRequestCulture = DefaultGetRequestCulture(defaultLanguage, languages),
SupportedCultures = languages SupportedCultures = languages
.Select(l => l.CultureName) .Select(l => l.CultureName)
.Distinct() .Distinct()
.Select(c => new CultureInfo(c)) .Select(c => new CultureInfo(c))
.ToArray(), .ToArray(),
SupportedUICultures = languages SupportedUICultures = languages
.Select(l => l.UiCultureName) .Select(l => l.UiCultureName)
.Distinct() .Distinct()
.Select(c => new CultureInfo(c)) .Select(c => new CultureInfo(c))
.ToArray() .ToArray()
}; };
_optionsAction?.Invoke(options); _optionsAction?.Invoke(options);
_requestLocalizationOptions = options; _requestLocalizationOptions = options;
}
} }
} }
} }
@ -98,4 +101,4 @@ namespace Microsoft.AspNetCore.RequestLocalization
return new RequestCulture(cultureName, uiCultureName); return new RequestCulture(cultureName, uiCultureName);
} }
} }
} }

4
modules/cms-kit/host/Volo.CmsKit.IdentityServer/Pages/Index.cshtml

@ -9,7 +9,7 @@
<abp-row> <abp-row>
<abp-column size-md="_3" class="text-center"> <abp-column size-md="_3" class="text-center">
<i class="fa fa-user d-block" style="font-size: 10em; color: #12b900"></i> <i class="fa fa-user d-block" style="font-size: 10em; color: #12b900"></i>
<a abp-button="Primary" asp-controller="Logout" asp-action="Index" asp-area="Account">Logout</a> <a href="/Account/Logout">Logout</a>
</abp-column> </abp-column>
<abp-column size-md="_9"> <abp-column size-md="_9">
<h2>@CurrentUser.UserName</h2> <h2>@CurrentUser.UserName</h2>
@ -31,4 +31,4 @@
<i class="fa fa-user d-block" style="font-size: 10em; color: #aaa"></i><br/><br /> <i class="fa fa-user d-block" style="font-size: 10em; color: #aaa"></i><br/><br />
<a abp-button="Primary" asp-page="/Account/Login">Login</a> <a abp-button="Primary" asp-page="/Account/Login">Login</a>
</div> </div>
} }

5
modules/cms-kit/host/Volo.CmsKit.Web.Unified/CmsKitWebUnifiedModule.cs

@ -113,11 +113,6 @@ namespace Volo.CmsKit
{ {
options.IsEnabled = MultiTenancyConsts.IsEnabled; options.IsEnabled = MultiTenancyConsts.IsEnabled;
}); });
Configure<CmsKitOptions>(options =>
{
options.PublicCommentEntities.Add("publicQuote");
});
} }
public override void OnApplicationInitialization(ApplicationInitializationContext context) public override void OnApplicationInitialization(ApplicationInitializationContext context)

32
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20200807070949_Reaction_Comment_Multitenancy.cs

@ -1,32 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Volo.CmsKit.Migrations
{
public partial class Reaction_Comment_Multitenancy : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Guid>(
name: "TenantId",
table: "CmsUserReactions",
nullable: true);
migrationBuilder.AddColumn<Guid>(
name: "TenantId",
table: "CmsComments",
nullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "TenantId",
table: "CmsUserReactions");
migrationBuilder.DropColumn(
name: "TenantId",
table: "CmsComments");
}
}
}

1186
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20200810022644_Initial.Designer.cs

File diff suppressed because it is too large

6
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20200807070949_Reaction_Comment_Multitenancy.Designer.cs → modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20200813130355_Initial.Designer.cs

@ -11,15 +11,15 @@ using Volo.CmsKit.EntityFrameworkCore;
namespace Volo.CmsKit.Migrations namespace Volo.CmsKit.Migrations
{ {
[DbContext(typeof(UnifiedDbContext))] [DbContext(typeof(UnifiedDbContext))]
[Migration("20200807070949_Reaction_Comment_Multitenancy")] [Migration("20200813130355_Initial")]
partial class Reaction_Comment_Multitenancy partial class Initial
{ {
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.SqlServer) .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.SqlServer)
.HasAnnotation("ProductVersion", "3.1.5") .HasAnnotation("ProductVersion", "3.1.6")
.HasAnnotation("Relational:MaxIdentifierLength", 128) .HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);

2
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20200810022644_Initial.cs → modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20200813130355_Initial.cs

@ -200,6 +200,7 @@ namespace Volo.CmsKit.Migrations
columns: table => new columns: table => new
{ {
Id = table.Column<Guid>(nullable: false), Id = table.Column<Guid>(nullable: false),
TenantId = table.Column<Guid>(nullable: true),
EntityType = table.Column<string>(maxLength: 64, nullable: false), EntityType = table.Column<string>(maxLength: 64, nullable: false),
EntityId = table.Column<string>(maxLength: 64, nullable: false), EntityId = table.Column<string>(maxLength: 64, nullable: false),
Text = table.Column<string>(maxLength: 512, nullable: false), Text = table.Column<string>(maxLength: 512, nullable: false),
@ -217,6 +218,7 @@ namespace Volo.CmsKit.Migrations
columns: table => new columns: table => new
{ {
Id = table.Column<Guid>(nullable: false), Id = table.Column<Guid>(nullable: false),
TenantId = table.Column<Guid>(nullable: true),
EntityType = table.Column<string>(maxLength: 64, nullable: false), EntityType = table.Column<string>(maxLength: 64, nullable: false),
EntityId = table.Column<string>(maxLength: 64, nullable: false), EntityId = table.Column<string>(maxLength: 64, nullable: false),
ReactionName = table.Column<string>(maxLength: 32, nullable: false), ReactionName = table.Column<string>(maxLength: 32, nullable: false),

8
modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Comments/CommentConsts.cs

@ -1,10 +1,12 @@
namespace Volo.CmsKit.Comments using Volo.CmsKit.Entities;
namespace Volo.CmsKit.Comments
{ {
public static class CommentConsts public static class CommentConsts
{ {
public static int EntityTypeLength { get; set; } = 64; public static int MaxEntityTypeLength { get; set; } = CmsEntityConsts.MaxEntityTypeLength;
public static int EntityIdLength { get; set; } = 64; public static int MaxEntityIdLength { get; set; } = CmsEntityConsts.MaxEntityIdLength;
public static int MaxTextLength { get; set; } = 512; public static int MaxTextLength { get; set; } = 512;
} }

9
modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Entities/CmsEntityConsts.cs

@ -0,0 +1,9 @@
namespace Volo.CmsKit.Entities
{
public class CmsEntityConsts
{
public static int MaxEntityTypeLength { get; set; } = 64;
public static int MaxEntityIdLength { get; set; } = 64;
}
}

5
modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/cs.json

@ -1,5 +0,0 @@
{
"culture": "cs",
"texts": {
}
}

6
modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/pl-PL.json

@ -1,6 +0,0 @@
{
"culture": "pl-PL",
"texts": {
}
}

6
modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/pt-BR.json

@ -1,6 +0,0 @@
{
"culture": "pt-BR",
"texts": {
}
}

5
modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/sl.json

@ -1,5 +0,0 @@
{
"culture": "sl",
"texts": {
}
}

14
modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/tr.json

@ -1,6 +1,18 @@
{ {
"culture": "tr", "culture": "tr",
"texts": { "texts": {
"PickYourReaction": "Tepkinizi seçin" "PickYourReaction": "Tepkinizi seçin",
"YourComment": "Yorumunuz",
"YourReply": "Cevabınız",
"Comments": "Yorumlar",
"Send": "Gönder",
"Delete": "Sil",
"Reply": "Cevapla",
"Update": "Güncelle",
"Edit": "Düzenle",
"LoginToAddComment": "Yorum yapmak için giriş yap",
"LoginToReply": "Cevap vermek için giriş yap",
"MessageDeletionConfirmationMessage": "Bu yorum tamamen silinecektir",
"CommentAuthorizationExceptionMessage": "Bu yorumları görebilmek için yetki gerekir."
} }
} }

5
modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/vi.json

@ -1,5 +0,0 @@
{
"culture": "vi",
"texts": {
}
}

5
modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/zh-Hans.json

@ -1,5 +0,0 @@
{
"culture": "zh-Hans",
"texts": {
}
}

5
modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/zh-Hant.json

@ -1,5 +0,0 @@
{
"culture": "zh-Hant",
"texts": {
}
}

10
modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Reactions/UserReactionConsts.cs

@ -1,11 +1,13 @@
namespace Volo.CmsKit.Reactions using Volo.CmsKit.Entities;
namespace Volo.CmsKit.Reactions
{ {
public static class UserReactionConsts public static class UserReactionConsts
{ {
public static int EntityTypeLength { get; set; } = 64; public static int MaxEntityTypeLength { get; set; } = CmsEntityConsts.MaxEntityTypeLength;
public static int EntityIdLength { get; set; } = 64; public static int MaxEntityIdLength { get; set; } = CmsEntityConsts.MaxEntityIdLength;
public static int ReactionNameLength { get; set; } = 32; public static int MaxReactionNameLength { get; set; } = 32;
} }
} }

7
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/CmsKitOptions.cs

@ -1,5 +1,4 @@
using System.Collections.Generic; using JetBrains.Annotations;
using JetBrains.Annotations;
using Volo.CmsKit.Reactions; using Volo.CmsKit.Reactions;
namespace Volo.CmsKit namespace Volo.CmsKit
@ -9,13 +8,9 @@ namespace Volo.CmsKit
[NotNull] [NotNull]
public ReactionDefinitionDictionary Reactions { get; } public ReactionDefinitionDictionary Reactions { get; }
[NotNull]
public List<string> PublicCommentEntities { get; }
public CmsKitOptions() public CmsKitOptions()
{ {
Reactions = new ReactionDefinitionDictionary(); Reactions = new ReactionDefinitionDictionary();
PublicCommentEntities = new List<string>();
} }
} }
} }

11
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/Comment.cs

@ -38,16 +38,21 @@ namespace Volo.CmsKit.Comments
Guid? tenantId = null) Guid? tenantId = null)
: base(id) : base(id)
{ {
EntityType = Check.NotNullOrWhiteSpace(entityType, nameof(entityType), CommentConsts.EntityTypeLength); EntityType = Check.NotNullOrWhiteSpace(entityType, nameof(entityType), CommentConsts.MaxEntityTypeLength);
EntityId = Check.NotNullOrWhiteSpace(entityId, nameof(entityId), CommentConsts.EntityIdLength); EntityId = Check.NotNullOrWhiteSpace(entityId, nameof(entityId), CommentConsts.MaxEntityIdLength);
RepliedCommentId = repliedCommentId; RepliedCommentId = repliedCommentId;
CreatorId = creatorId; CreatorId = creatorId;
TenantId = tenantId; TenantId = tenantId;
SetText(text); SetTextInternal(text);
} }
public virtual void SetText(string text) public virtual void SetText(string text)
{
SetTextInternal(text);
}
protected virtual void SetTextInternal(string text)
{ {
Text = Check.NotNullOrWhiteSpace(text, nameof(text), CommentConsts.MaxTextLength); Text = Check.NotNullOrWhiteSpace(text, nameof(text), CommentConsts.MaxTextLength);
} }

2
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/CommentWithAuthor.cs → modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/CommentWithAuthorQueryResultItem.cs

@ -2,7 +2,7 @@
namespace Volo.CmsKit.Comments namespace Volo.CmsKit.Comments
{ {
public class CommentWithAuthor public class CommentWithAuthorQueryResultItem
{ {
public Comment Comment { get; set; } public Comment Comment { get; set; }

5
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/ICommentRepository.cs

@ -8,8 +8,9 @@ namespace Volo.CmsKit.Comments
{ {
public interface ICommentRepository : IBasicRepository<Comment, Guid> public interface ICommentRepository : IBasicRepository<Comment, Guid>
{ {
Task<List<CommentWithAuthor>> GetListWithAuthorsAsync( Task<List<CommentWithAuthorQueryResultItem>> GetListWithAuthorsAsync(
[NotNull] string entityType, [NotNull] string entityType,
[NotNull] string entityId); [NotNull] string entityId
);
} }
} }

2
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/DefaultReactionDefinitionStore.cs

@ -20,7 +20,7 @@ namespace Volo.CmsKit.Reactions
return Task.FromResult(Options.Reactions.Values.ToList()); return Task.FromResult(Options.Reactions.Values.ToList());
} }
public Task<ReactionDefinition> GetReactionOrNullAsync(string reactionName, string entityType = null) public virtual Task<ReactionDefinition> GetReactionOrNullAsync(string reactionName, string entityType = null)
{ {
return Task.FromResult(Options.Reactions.GetOrDefault(reactionName)); return Task.FromResult(Options.Reactions.GetOrDefault(reactionName));
} }

9
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/IUserReactionRepository.cs

@ -12,15 +12,18 @@ namespace Volo.CmsKit.Reactions
Guid userId, Guid userId,
[NotNull] string entityType, [NotNull] string entityType,
[NotNull] string entityId, [NotNull] string entityId,
[NotNull] string reactionName); [NotNull] string reactionName
);
Task<List<UserReaction>> GetListForUserAsync( Task<List<UserReaction>> GetListForUserAsync(
Guid userId, Guid userId,
[NotNull] string entityType, [NotNull] string entityType,
[NotNull] string entityId); [NotNull] string entityId
);
Task<List<ReactionSummaryQueryResultItem>> GetSummariesAsync( Task<List<ReactionSummaryQueryResultItem>> GetSummariesAsync(
[NotNull] string entityType, [NotNull] string entityType,
[NotNull] string entityId); [NotNull] string entityId
);
} }
} }

1
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Users/CmsUserLookupService.cs

@ -19,6 +19,5 @@ namespace Volo.CmsKit.Users
{ {
return new CmsUser(externalUser); return new CmsUser(externalUser);
} }
} }
} }

4
modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs

@ -19,7 +19,7 @@ namespace Volo.CmsKit.Comments
{ {
} }
public async Task<List<CommentWithAuthor>> GetListWithAuthorsAsync( public async Task<List<CommentWithAuthorQueryResultItem>> GetListWithAuthorsAsync(
string entityType, string entityType,
string entityId) string entityId)
{ {
@ -30,7 +30,7 @@ namespace Volo.CmsKit.Comments
join user in DbContext.CmsUsers on comment.CreatorId equals user.Id join user in DbContext.CmsUsers on comment.CreatorId equals user.Id
where entityType == comment.EntityType && entityId == comment.EntityId where entityType == comment.EntityType && entityId == comment.EntityId
orderby comment.CreationTime orderby comment.CreationTime
select new CommentWithAuthor select new CommentWithAuthorQueryResultItem
{ {
Comment = comment, Comment = comment,
Author = user Author = user

10
modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContextModelCreatingExtensions.cs

@ -37,9 +37,9 @@ namespace Volo.CmsKit.EntityFrameworkCore
b.ToTable(options.TablePrefix + "UserReactions", options.Schema); b.ToTable(options.TablePrefix + "UserReactions", options.Schema);
b.ConfigureByConvention(); b.ConfigureByConvention();
b.Property(x => x.EntityType).IsRequired().HasMaxLength(UserReactionConsts.EntityTypeLength); b.Property(x => x.EntityType).IsRequired().HasMaxLength(UserReactionConsts.MaxEntityTypeLength);
b.Property(x => x.EntityId).IsRequired().HasMaxLength(UserReactionConsts.EntityIdLength); b.Property(x => x.EntityId).IsRequired().HasMaxLength(UserReactionConsts.MaxEntityIdLength);
b.Property(x => x.ReactionName).IsRequired().HasMaxLength(UserReactionConsts.ReactionNameLength); b.Property(x => x.ReactionName).IsRequired().HasMaxLength(UserReactionConsts.MaxReactionNameLength);
b.Property(x => x.CreationTime); b.Property(x => x.CreationTime);
b.HasIndex(x => new { x.EntityType, x.EntityId }); b.HasIndex(x => new { x.EntityType, x.EntityId });
@ -51,8 +51,8 @@ namespace Volo.CmsKit.EntityFrameworkCore
b.ToTable(options.TablePrefix + "Comments", options.Schema); b.ToTable(options.TablePrefix + "Comments", options.Schema);
b.ConfigureByConvention(); b.ConfigureByConvention();
b.Property(x => x.EntityType).IsRequired().HasMaxLength(CommentConsts.EntityTypeLength); b.Property(x => x.EntityType).IsRequired().HasMaxLength(CommentConsts.MaxEntityTypeLength);
b.Property(x => x.EntityId).IsRequired().HasMaxLength(CommentConsts.EntityIdLength); b.Property(x => x.EntityId).IsRequired().HasMaxLength(CommentConsts.MaxEntityIdLength);
b.Property(x => x.Text).IsRequired().HasMaxLength(CommentConsts.MaxTextLength); b.Property(x => x.Text).IsRequired().HasMaxLength(CommentConsts.MaxTextLength);
b.Property(x => x.RepliedCommentId); b.Property(x => x.RepliedCommentId);
b.Property(x => x.CreationTime); b.Property(x => x.CreationTime);

4
modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs

@ -18,7 +18,7 @@ namespace Volo.CmsKit.MongoDB.Comments
{ {
} }
public async Task<List<CommentWithAuthor>> GetListWithAuthorsAsync( public async Task<List<CommentWithAuthorQueryResultItem>> GetListWithAuthorsAsync(
string entityType, string entityType,
string entityId) string entityId)
{ {
@ -40,7 +40,7 @@ namespace Volo.CmsKit.MongoDB.Comments
return comments return comments
.Select( .Select(
comment => comment =>
new CommentWithAuthor new CommentWithAuthorQueryResultItem
{ {
Comment = comment, Comment = comment,
Author = authors.FirstOrDefault(a => a.Id == comment.CreatorId) Author = authors.FirstOrDefault(a => a.Id == comment.CreatorId)

4
modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/CreateCommentInput.cs

@ -8,11 +8,11 @@ namespace Volo.CmsKit.Public.Comments
public class CreateCommentInput public class CreateCommentInput
{ {
[Required] [Required]
[DynamicStringLength(typeof(CommentConsts), nameof(CommentConsts.EntityTypeLength))] [DynamicStringLength(typeof(CommentConsts), nameof(CommentConsts.MaxEntityTypeLength))]
public string EntityType { get; set; } public string EntityType { get; set; }
[Required] [Required]
[DynamicStringLength(typeof(CommentConsts), nameof(CommentConsts.EntityIdLength))] [DynamicStringLength(typeof(CommentConsts), nameof(CommentConsts.MaxEntityIdLength))]
public string EntityId { get; set; } public string EntityId { get; set; }
[Required] [Required]

24
modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Comments/CommentPublicAppService.cs

@ -33,8 +33,6 @@ namespace Volo.CmsKit.Public.Comments
public virtual async Task<ListResultDto<CommentWithDetailsDto>> GetAllForEntityAsync(string entityType, string entityId) public virtual async Task<ListResultDto<CommentWithDetailsDto>> GetAllForEntityAsync(string entityType, string entityId)
{ {
CheckAuthorizationAsync(entityType);
var commentsWithAuthor = await CommentRepository.GetListWithAuthorsAsync(entityType, entityId); var commentsWithAuthor = await CommentRepository.GetListWithAuthorsAsync(entityType, entityId);
return new ListResultDto<CommentWithDetailsDto>( return new ListResultDto<CommentWithDetailsDto>(
@ -95,7 +93,7 @@ namespace Volo.CmsKit.Public.Comments
await CommentRepository.DeleteAsync(id); await CommentRepository.DeleteAsync(id);
} }
private List<CommentWithDetailsDto> ConvertCommentsToNestedStructure(List<CommentWithAuthor> comments) private List<CommentWithDetailsDto> ConvertCommentsToNestedStructure(List<CommentWithAuthorQueryResultItem> comments)
{ {
var parentComments = comments var parentComments = comments
.Where(c=> c.Comment.RepliedCommentId == null) .Where(c=> c.Comment.RepliedCommentId == null)
@ -120,25 +118,7 @@ namespace Volo.CmsKit.Public.Comments
return parentComments; return parentComments;
} }
private async Task CheckAuthorizationAsync(string entityType) private CmsUserDto GetAuthorAsDtoFromCommentList(List<CommentWithAuthorQueryResultItem> comments, Guid commentId)
{
if (await IsPublicEntity(entityType))
{
return;
}
if (!CurrentUser.IsAuthenticated)
{
throw new AbpAuthorizationException(L["CommentAuthorizationExceptionMessage"]);
}
}
private async Task<bool> IsPublicEntity(string entityType)
{
return CmsKitOptions.PublicCommentEntities.Contains(entityType);
}
private CmsUserDto GetAuthorAsDtoFromCommentList(List<CommentWithAuthor> comments, Guid commentId)
{ {
return ObjectMapper.Map<CmsUser, CmsUserDto>(comments.Single(c => c.Comment.Id == commentId).Author); return ObjectMapper.Map<CmsUser, CmsUserDto>(comments.Single(c => c.Comment.Id == commentId).Author);
} }

17
modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Reactions/ReactionPublicAppService.cs

@ -31,13 +31,14 @@ namespace Volo.CmsKit.Public.Reactions
{ {
var summaries = await ReactionManager.GetSummariesAsync(entityType, entityId); var summaries = await ReactionManager.GetSummariesAsync(entityType, entityId);
var userReactions = CurrentUser.IsAuthenticated ? var userReactionsOrNull = CurrentUser.IsAuthenticated
(await UserReactionRepository ? (await UserReactionRepository
.GetListForUserAsync( .GetListForUserAsync(
CurrentUser.GetId(), CurrentUser.GetId(),
entityType, entityType,
entityId entityId
)).ToDictionary(x => x.ReactionName, x => x) : null; )).ToDictionary(x => x.ReactionName, x => x)
: null;
var reactionWithSelectionDtos = new List<ReactionWithSelectionDto>(); var reactionWithSelectionDtos = new List<ReactionWithSelectionDto>();
@ -48,7 +49,7 @@ namespace Volo.CmsKit.Public.Reactions
{ {
Reaction = ConvertToReactionDto(summary.Reaction), Reaction = ConvertToReactionDto(summary.Reaction),
Count = summary.Count, Count = summary.Count,
IsSelectedByCurrentUser = userReactions?.ContainsKey(summary.Reaction.Name) ?? false IsSelectedByCurrentUser = userReactionsOrNull?.ContainsKey(summary.Reaction.Name) ?? false
} }
); );
} }

1
modules/cms-kit/test/Volo.CmsKit.Application.Tests/Reactions/ReactionPublicAppService_Tests.cs

@ -43,6 +43,7 @@ namespace Volo.CmsKit.Reactions
reactions.Items. reactions.Items.
First(r=>r.Reaction.Name == StandardReactions.Rocket).IsSelectedByCurrentUser.ShouldBeTrue(); First(r=>r.Reaction.Name == StandardReactions.Rocket).IsSelectedByCurrentUser.ShouldBeTrue();
reactions.Items. reactions.Items.
First(r=>r.Reaction.Name == StandardReactions.Rocket).Count.ShouldBe(1); First(r=>r.Reaction.Name == StandardReactions.Rocket).Count.ShouldBe(1);

8
modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/en.json

@ -84,10 +84,10 @@
"DisplayName:Abp.Identity.Lockout.LockoutDuration": "Lockout duration(seconds)", "DisplayName:Abp.Identity.Lockout.LockoutDuration": "Lockout duration(seconds)",
"DisplayName:Abp.Identity.Lockout.MaxFailedAccessAttempts": "Max failed access attempts", "DisplayName:Abp.Identity.Lockout.MaxFailedAccessAttempts": "Max failed access attempts",
"DisplayName:Abp.Identity.SignIn.RequireConfirmedEmail": "Require confirmed email", "DisplayName:Abp.Identity.SignIn.RequireConfirmedEmail": "Require confirmed email",
"DisplayName:Abp.Identity.SignIn.EnablePhoneNumberConfirmation": "Enable phone number confirmation", "DisplayName:Abp.Identity.SignIn.EnablePhoneNumberConfirmation": "Allow users to confirm their phone number",
"DisplayName:Abp.Identity.SignIn.RequireConfirmedPhoneNumber": "Require confirmed phoneNumber", "DisplayName:Abp.Identity.SignIn.RequireConfirmedPhoneNumber": "Require confirmed phone number",
"DisplayName:Abp.Identity.User.IsUserNameUpdateEnabled": "Is username update enabled", "DisplayName:Abp.Identity.User.IsUserNameUpdateEnabled": "Allow users to change their usernames",
"DisplayName:Abp.Identity.User.IsEmailUpdateEnabled": "Is email update enabled", "DisplayName:Abp.Identity.User.IsEmailUpdateEnabled": "Allow users to change their email addresses",
"Description:Abp.Identity.Password.RequiredLength": "The minimum length a password must be.", "Description:Abp.Identity.Password.RequiredLength": "The minimum length a password must be.",
"Description:Abp.Identity.Password.RequiredUniqueChars": "The minimum number of unique characters which a password must contain.", "Description:Abp.Identity.Password.RequiredUniqueChars": "The minimum number of unique characters which a password must contain.",
"Description:Abp.Identity.Password.RequireNonAlphanumeric": "If passwords must contain a non-alphanumeric character.", "Description:Abp.Identity.Password.RequireNonAlphanumeric": "If passwords must contain a non-alphanumeric character.",

3
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/appsettings.json

@ -11,7 +11,8 @@
}, },
"MyProjectName_App": { "MyProjectName_App": {
"ClientId": "MyProjectName_App", "ClientId": "MyProjectName_App",
"ClientSecret": "1q2w3e*" "ClientSecret": "1q2w3e*",
"RootUrl": "http://localhost:4200"
} }
} }
} }

23
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/IdentityServer/IdentityServerDataSeedContributor.cs

@ -126,15 +126,20 @@ namespace MyCompanyName.MyProjectName.IdentityServer
); );
} }
//Console Test Client //Console Test / Angular Client
var consoleClientId = configurationSection["MyProjectName_App:ClientId"]; var consoleAndAngularClientId = configurationSection["MyProjectName_App:ClientId"];
if (!consoleClientId.IsNullOrWhiteSpace()) if (!consoleAndAngularClientId.IsNullOrWhiteSpace())
{ {
var webClientRootUrl = configurationSection["MyProjectName_App:RootUrl"]?.TrimEnd('/');
await CreateClientAsync( await CreateClientAsync(
name: consoleClientId, name: consoleAndAngularClientId,
scopes: commonScopes, scopes: commonScopes,
grantTypes: new[] {"password", "client_credentials"}, grantTypes: new[] {"password", "client_credentials", "authorization_code"},
secret: (configurationSection["MyProjectName_App:ClientSecret"] ?? "1q2w3e*").Sha256() secret: (configurationSection["MyProjectName_App:ClientSecret"] ?? "1q2w3e*").Sha256(),
requireClientSecret: false,
redirectUri: webClientRootUrl,
postLogoutRedirectUri: webClientRootUrl
); );
} }
} }
@ -147,6 +152,8 @@ namespace MyCompanyName.MyProjectName.IdentityServer
string redirectUri = null, string redirectUri = null,
string postLogoutRedirectUri = null, string postLogoutRedirectUri = null,
string frontChannelLogoutUri = null, string frontChannelLogoutUri = null,
bool requireClientSecret = true,
bool requirePkce = false,
IEnumerable<string> permissions = null) IEnumerable<string> permissions = null)
{ {
var client = await _clientRepository.FindByCliendIdAsync(name); var client = await _clientRepository.FindByCliendIdAsync(name);
@ -168,7 +175,9 @@ namespace MyCompanyName.MyProjectName.IdentityServer
AuthorizationCodeLifetime = 300, AuthorizationCodeLifetime = 300,
IdentityTokenLifetime = 300, IdentityTokenLifetime = 300,
RequireConsent = false, RequireConsent = false,
FrontChannelLogoutUri = frontChannelLogoutUri FrontChannelLogoutUri = frontChannelLogoutUri,
RequireClientSecret = requireClientSecret,
RequirePkce = requirePkce
}, },
autoSave: true autoSave: true
); );

6
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs

@ -167,7 +167,10 @@ namespace MyCompanyName.MyProjectName
{ {
app.UseDeveloperExceptionPage(); app.UseDeveloperExceptionPage();
} }
else
app.UseAbpRequestLocalization();
if (!env.IsDevelopment())
{ {
app.UseErrorPage(); app.UseErrorPage();
} }
@ -183,7 +186,6 @@ namespace MyCompanyName.MyProjectName
app.UseMultiTenancy(); app.UseMultiTenancy();
} }
app.UseAbpRequestLocalization();
app.UseAuthorization(); app.UseAuthorization();
app.UseSwagger(); app.UseSwagger();

6
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/MyProjectNameHttpApiHostModule.cs

@ -160,7 +160,10 @@ namespace MyCompanyName.MyProjectName
{ {
app.UseDeveloperExceptionPage(); app.UseDeveloperExceptionPage();
} }
else
app.UseAbpRequestLocalization();
if (!env.IsDevelopment())
{ {
app.UseErrorPage(); app.UseErrorPage();
} }
@ -177,7 +180,6 @@ namespace MyCompanyName.MyProjectName
app.UseMultiTenancy(); app.UseMultiTenancy();
} }
app.UseAbpRequestLocalization();
app.UseIdentityServer(); app.UseIdentityServer();
app.UseAuthorization(); app.UseAuthorization();

6
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs

@ -143,7 +143,10 @@ namespace MyCompanyName.MyProjectName
{ {
app.UseDeveloperExceptionPage(); app.UseDeveloperExceptionPage();
} }
else
app.UseAbpRequestLocalization();
if (!env.IsDevelopment())
{ {
app.UseErrorPage(); app.UseErrorPage();
} }
@ -159,7 +162,6 @@ namespace MyCompanyName.MyProjectName
app.UseMultiTenancy(); app.UseMultiTenancy();
} }
app.UseAbpRequestLocalization();
app.UseIdentityServer(); app.UseIdentityServer();
app.UseAuthorization(); app.UseAuthorization();
app.UseAuditing(); app.UseAuditing();

6
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebModule.cs

@ -215,7 +215,10 @@ namespace MyCompanyName.MyProjectName.Web
{ {
app.UseDeveloperExceptionPage(); app.UseDeveloperExceptionPage();
} }
else
app.UseAbpRequestLocalization();
if (!env.IsDevelopment())
{ {
app.UseErrorPage(); app.UseErrorPage();
} }
@ -230,7 +233,6 @@ namespace MyCompanyName.MyProjectName.Web
app.UseMultiTenancy(); app.UseMultiTenancy();
} }
app.UseAbpRequestLocalization();
app.UseAuthorization(); app.UseAuthorization();
app.UseSwagger(); app.UseSwagger();

6
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs

@ -191,7 +191,10 @@ namespace MyCompanyName.MyProjectName.Web
{ {
app.UseDeveloperExceptionPage(); app.UseDeveloperExceptionPage();
} }
else
app.UseAbpRequestLocalization();
if (!env.IsDevelopment())
{ {
app.UseErrorPage(); app.UseErrorPage();
} }
@ -207,7 +210,6 @@ namespace MyCompanyName.MyProjectName.Web
app.UseMultiTenancy(); app.UseMultiTenancy();
} }
app.UseAbpRequestLocalization();
app.UseIdentityServer(); app.UseIdentityServer();
app.UseAuthorization(); app.UseAuthorization();
app.UseSwagger(); app.UseSwagger();

Loading…
Cancel
Save