Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: category authentication redirect url. #1264

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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