mirror of https://github.com/halo-dev/halo
fix: user page not found (#3736)
#### What type of PR is this? /kind bug /area core #### What this PR does / why we need it: 修复作者页无法访问的问题 #### Which issue(s) this PR fixes: Fixes #3718 #### Does this PR introduce a user-facing change? ```release-note 修复作者页无法访问的问题 ```pull/3740/head
parent
d7bfbef149
commit
d1651aa671
|
@ -127,6 +127,7 @@ public class ThemeCompositeRouterFunction implements RouterFunction<ServerRespon
|
|||
|
||||
// Add the index route to the end to prevent conflict with the queryParam rule of the post
|
||||
routePatterns.add(new RoutePattern(DefaultTemplateEnum.INDEX, "/"));
|
||||
routePatterns.add(new RoutePattern(DefaultTemplateEnum.AUTHOR, ""));
|
||||
return routePatterns;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import run.halo.app.core.extension.User;
|
|||
import run.halo.app.extension.ReactiveExtensionClient;
|
||||
import run.halo.app.infra.SystemConfigurableEnvironmentFetcher;
|
||||
import run.halo.app.infra.SystemSetting;
|
||||
import run.halo.app.infra.exception.NotFoundException;
|
||||
import run.halo.app.theme.DefaultTemplateEnum;
|
||||
import run.halo.app.theme.finders.PostFinder;
|
||||
import run.halo.app.theme.finders.vo.ListedPostVo;
|
||||
|
@ -73,7 +74,8 @@ public class AuthorPostsRouteFactory implements RouteFactory {
|
|||
}
|
||||
|
||||
private Mono<UserVo> getByName(String name) {
|
||||
return client.get(User.class, name)
|
||||
return client.fetch(User.class, name)
|
||||
.switchIfEmpty(Mono.error(() -> new NotFoundException("Author page not found.")))
|
||||
.map(UserVo::from);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ class AuthorPostsRouteFactoryTest extends RouteFactoryTestSuite {
|
|||
RouterFunction<ServerResponse> routerFunction = authorPostsRouteFactory.create(null);
|
||||
WebTestClient webClient = getWebTestClient(routerFunction);
|
||||
|
||||
when(client.get(eq(User.class), eq("fake-user")))
|
||||
when(client.fetch(eq(User.class), eq("fake-user")))
|
||||
.thenReturn(Mono.just(new User()));
|
||||
webClient.get()
|
||||
.uri("/authors/fake-user")
|
||||
|
|
Loading…
Reference in New Issue