|
|
|
@ -3,6 +3,7 @@ using System.Threading.Tasks; |
|
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
using Microsoft.Extensions.Options; |
|
|
|
using Volo.Abp; |
|
|
|
using Volo.Abp.AspNetCore.Mvc; |
|
|
|
using Volo.Abp.ObjectMapping; |
|
|
|
using Volo.CmsKit.Comments; |
|
|
|
@ -13,7 +14,7 @@ using Volo.CmsKit.Public.Web.Security.Captcha; |
|
|
|
namespace Volo.CmsKit.Public.Web.Controllers; |
|
|
|
|
|
|
|
//[Route("cms-kit/public-comments")]
|
|
|
|
public class CmsKitPublicCommentsController : AbpController |
|
|
|
public class CmsKitPublicCommentsController : CmsKitPublicControllerBase |
|
|
|
{ |
|
|
|
public ICommentPublicAppService CommentPublicAppService { get; } |
|
|
|
protected CmsKitCommentOptions CmsKitCommentOptions { get; } |
|
|
|
@ -32,8 +33,10 @@ public class CmsKitPublicCommentsController : AbpController |
|
|
|
[HttpPost] |
|
|
|
public virtual async Task ValidateAsync([FromBody] CreateCommentWithParametersInput input) |
|
|
|
{ |
|
|
|
if (CmsKitCommentOptions.IsRecaptchaEnabled && input.CaptchaToken.HasValue) |
|
|
|
if (CmsKitCommentOptions.IsRecaptchaEnabled) |
|
|
|
{ |
|
|
|
CheckCaptchaTokenNullity(input.CaptchaToken); |
|
|
|
|
|
|
|
SimpleMathsCaptchaGenerator.Validate(input.CaptchaToken.Value, input.CaptchaAnswer); |
|
|
|
} |
|
|
|
|
|
|
|
@ -44,11 +47,21 @@ public class CmsKitPublicCommentsController : AbpController |
|
|
|
[HttpPost] |
|
|
|
public virtual async Task UpdateAsync(Guid id, [FromBody] UpdateCommentInput input) |
|
|
|
{ |
|
|
|
if (CmsKitCommentOptions.IsRecaptchaEnabled && input.CaptchaToken.HasValue) |
|
|
|
if (CmsKitCommentOptions.IsRecaptchaEnabled) |
|
|
|
{ |
|
|
|
CheckCaptchaTokenNullity(input.CaptchaToken); |
|
|
|
|
|
|
|
SimpleMathsCaptchaGenerator.Validate(input.CaptchaToken.Value, input.CaptchaAnswer); |
|
|
|
} |
|
|
|
|
|
|
|
await CommentPublicAppService.UpdateAsync(id, input); |
|
|
|
} |
|
|
|
|
|
|
|
private void CheckCaptchaTokenNullity(Guid? captchaToken) |
|
|
|
{ |
|
|
|
if (!captchaToken.HasValue) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException(L["CaptchaCodeMissingMessage"]); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|