Skip to content

Commit

Permalink
fix: category authentication redirect url. (#1264)
Browse files Browse the repository at this point in the history
  • Loading branch information
ruibaby authored Feb 8, 2021
1 parent d509305 commit f567b94
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);

Expand All @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
</head>
<body>
<div class="container">
<form method="post" action="${blog_url!}/archives/${type!}/${slug!}/password">
<form method="post" action="${blog_url!}/content/${type!}/${slug!}/authentication">
<div class="password-input">
<input type="password" name="password" placeholder="请输入访问密码">
<span class="bottom"></span>
Expand Down

0 comments on commit f567b94

Please sign in to comment.