diff --git a/application/src/main/java/run/halo/app/security/LogoutSecurityConfigurer.java b/application/src/main/java/run/halo/app/security/LogoutSecurityConfigurer.java index 1cf8effe5..b6bf4ec12 100644 --- a/application/src/main/java/run/halo/app/security/LogoutSecurityConfigurer.java +++ b/application/src/main/java/run/halo/app/security/LogoutSecurityConfigurer.java @@ -11,6 +11,8 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.security.config.web.server.ServerHttpSecurity; import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.ReactiveSecurityContextHolder; +import org.springframework.security.core.context.SecurityContext; import org.springframework.security.web.server.WebFilterExchange; import org.springframework.security.web.server.authentication.logout.DelegatingServerLogoutHandler; import org.springframework.security.web.server.authentication.logout.RedirectServerLogoutSuccessHandler; @@ -21,6 +23,7 @@ import org.springframework.web.reactive.function.server.RouterFunction; import org.springframework.web.reactive.function.server.RouterFunctions; import org.springframework.web.reactive.function.server.ServerResponse; import reactor.core.publisher.Mono; +import run.halo.app.core.user.service.UserService; import run.halo.app.security.authentication.SecurityConfigurer; import run.halo.app.security.authentication.rememberme.RememberMeServices; @@ -55,13 +58,18 @@ public class LogoutSecurityConfigurer implements SecurityConfigurer { } @Bean - RouterFunction logoutPage() { + RouterFunction logoutPage(UserService userService) { return RouterFunctions.route() .GET("/logout", request -> { + var user = ReactiveSecurityContextHolder.getContext() + .map(SecurityContext::getAuthentication) + .map(Authentication::getName) + .flatMap(userService::getUser); var exchange = request.exchange(); var contextPath = exchange.getRequest().getPath().contextPath().value(); return ServerResponse.ok().render("logout", Map.of( - "action", contextPath + "/logout" + "action", contextPath + "/logout", + "user", user )); }) .build(); diff --git a/application/src/main/resources/templates/gateway_fragments/logout.html b/application/src/main/resources/templates/gateway_fragments/logout.html index 84013bb58..2a4c49dbd 100644 --- a/application/src/main/resources/templates/gateway_fragments/logout.html +++ b/application/src/main/resources/templates/gateway_fragments/logout.html @@ -1,5 +1,16 @@
+
-
\ No newline at end of file + +
+ +
+ diff --git a/application/src/main/resources/templates/gateway_fragments/logout.properties b/application/src/main/resources/templates/gateway_fragments/logout.properties index 0ad6b90f0..4d110365e 100644 --- a/application/src/main/resources/templates/gateway_fragments/logout.properties +++ b/application/src/main/resources/templates/gateway_fragments/logout.properties @@ -1 +1,3 @@ -form.submit=退出登录 \ No newline at end of file +form.submit=退出登录 +form.cancel=取消 +form.currentUser.label=当前登录的用户: \ No newline at end of file diff --git a/application/src/main/resources/templates/gateway_fragments/logout_en.properties b/application/src/main/resources/templates/gateway_fragments/logout_en.properties index 6f8a3da34..de423bad6 100644 --- a/application/src/main/resources/templates/gateway_fragments/logout_en.properties +++ b/application/src/main/resources/templates/gateway_fragments/logout_en.properties @@ -1 +1,3 @@ -form.submit=Logout \ No newline at end of file +form.submit=Logout +form.cancel=Cancel +form.currentUser.label=Currently logged in user: \ No newline at end of file diff --git a/application/src/main/resources/templates/gateway_fragments/logout_es.properties b/application/src/main/resources/templates/gateway_fragments/logout_es.properties index 3fda0b0f1..f6264e15c 100644 --- a/application/src/main/resources/templates/gateway_fragments/logout_es.properties +++ b/application/src/main/resources/templates/gateway_fragments/logout_es.properties @@ -1 +1,3 @@ -form.submit=Cerrar Sesión \ No newline at end of file +form.submit=Cerrar Sesión +form.cancel=Cancelar +form.currentUser.label=Usuario actualmente conectado: diff --git a/application/src/main/resources/templates/gateway_fragments/logout_zh_TW.properties b/application/src/main/resources/templates/gateway_fragments/logout_zh_TW.properties index 2cbbd7523..86ccd7e15 100644 --- a/application/src/main/resources/templates/gateway_fragments/logout_zh_TW.properties +++ b/application/src/main/resources/templates/gateway_fragments/logout_zh_TW.properties @@ -1 +1,3 @@ -form.submit=退出登入 \ No newline at end of file +form.submit=退出登入 +form.cancel=取消 +form.currentUser.label=當前登入的使用者: \ No newline at end of file diff --git a/application/src/main/resources/templates/logout.html b/application/src/main/resources/templates/logout.html index a91195c41..fd0890184 100644 --- a/application/src/main/resources/templates/logout.html +++ b/application/src/main/resources/templates/logout.html @@ -1,14 +1,55 @@ - + -
+
+

+
+ + + +