From f567b94f919f9692a49706f1f7e59d5a65908c49 Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Mon, 8 Feb 2021 19:22:20 +0800 Subject: [PATCH] fix: category authentication redirect url. (#1264) --- .../content/ContentContentController.java | 13 +++++++------ .../templates/common/template/post_password.ftl | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/run/halo/app/controller/content/ContentContentController.java b/src/main/java/run/halo/app/controller/content/ContentContentController.java index 9cbef445ca..01c73b3e9d 100644 --- a/src/main/java/run/halo/app/controller/content/ContentContentController.java +++ b/src/main/java/run/halo/app/controller/content/ContentContentController.java @@ -23,8 +23,8 @@ import run.halo.app.controller.content.model.TagModel; import run.halo.app.exception.NotFoundException; import run.halo.app.exception.UnsupportedException; +import run.halo.app.model.dto.CategoryDTO; import run.halo.app.model.dto.post.BasePostMinimalDTO; -import run.halo.app.model.entity.Category; import run.halo.app.model.entity.Post; import run.halo.app.model.entity.Sheet; import run.halo.app.model.enums.EncryptTypeEnum; @@ -83,8 +83,8 @@ public ContentContentController(PostModel postModel, PostService postService, SheetService sheetService, AbstractStringCacheStore cacheStore, - AuthenticationService authenticationService, - CategoryService categoryService) { + AuthenticationService authenticationService, + CategoryService categoryService) { this.postModel = postModel; this.sheetModel = sheetModel; this.categoryModel = categoryModel; @@ -236,7 +236,7 @@ public String content(@PathVariable("year") Integer year, throw new NotFoundException("Not Found"); } - @PostMapping(value = "archives/{type}/{slug:.*}/password") + @PostMapping(value = "content/{type}/{slug:.*}/authentication") @CacheLock(traceRequest = true, expired = 2) public String password(@PathVariable("type") String type, @PathVariable("slug") String slug, @@ -276,7 +276,8 @@ private String doAuthenticationPost( } private String doAuthenticationCategory(String slug, String password) { - Category category = categoryService.getBySlugOfNonNull(slug, true); + CategoryDTO + category = categoryService.convertTo(categoryService.getBySlugOfNonNull(slug, true)); authenticationService.categoryAuthentication(category.getId(), password); @@ -286,7 +287,7 @@ private String doAuthenticationCategory(String slug, String password) { redirectUrl.append(optionService.getBlogBaseUrl()); } - redirectUrl.append(optionService.getCategoriesPrefix()).append(slug); + redirectUrl.append(category.getFullPath()); return redirectUrl.toString(); } diff --git a/src/main/resources/templates/common/template/post_password.ftl b/src/main/resources/templates/common/template/post_password.ftl index 17d89f334c..7f70f7f3be 100644 --- a/src/main/resources/templates/common/template/post_password.ftl +++ b/src/main/resources/templates/common/template/post_password.ftl @@ -152,7 +152,7 @@
-
+