feat: privateなときは登録フォームへのリンクを出さないように

登録自体はまだできる
This commit is contained in:
usbharu 2024-09-05 12:59:25 +09:00
parent aa34fb0370
commit df6d2940ed
Signed by: usbharu
GPG Key ID: 6556747BF94EEBC8
3 changed files with 10 additions and 4 deletions

View File

@ -23,6 +23,7 @@ class GetLocalInstanceApplicationService(
override suspend fun internalExecute(command: Unit, principal: Principal): Instance { override suspend fun internalExecute(command: Unit, principal: Principal): Instance {
if (cachedInstance != null) { if (cachedInstance != null) {
logger.trace("Use cache {}", cachedInstance)
@Suppress("UnsafeCallOnNullableType") @Suppress("UnsafeCallOnNullableType")
return cachedInstance!! return cachedInstance!!
} }

View File

@ -1,6 +1,8 @@
package dev.usbharu.hideout.core.interfaces.web package dev.usbharu.hideout.core.interfaces.web
import dev.usbharu.hideout.core.application.instance.GetLocalInstanceApplicationService
import dev.usbharu.hideout.core.config.ApplicationConfig import dev.usbharu.hideout.core.config.ApplicationConfig
import dev.usbharu.hideout.core.domain.model.support.principal.Anonymous
import dev.usbharu.hideout.core.infrastructure.springframework.SpringSecurityFormLoginPrincipalContextHolder import dev.usbharu.hideout.core.infrastructure.springframework.SpringSecurityFormLoginPrincipalContextHolder
import org.springframework.stereotype.Controller import org.springframework.stereotype.Controller
import org.springframework.ui.Model import org.springframework.ui.Model
@ -9,7 +11,8 @@ import org.springframework.web.bind.annotation.GetMapping
@Controller @Controller
class IndexController( class IndexController(
private val applicationConfig: ApplicationConfig, private val applicationConfig: ApplicationConfig,
private val springSecurityFormLoginPrincipalContextHolder: SpringSecurityFormLoginPrincipalContextHolder private val springSecurityFormLoginPrincipalContextHolder: SpringSecurityFormLoginPrincipalContextHolder,
private val getLocalInstanceApplicationService: GetLocalInstanceApplicationService
) { ) {
@GetMapping("/") @GetMapping("/")
suspend fun index(model: Model): String { suspend fun index(model: Model): String {
@ -17,7 +20,8 @@ class IndexController(
return "redirect:/home" return "redirect:/home"
} }
val instance = getLocalInstanceApplicationService.execute(Unit, Anonymous)
model.addAttribute("instance", instance)
model.addAttribute("applicationConfig", applicationConfig) model.addAttribute("applicationConfig", applicationConfig)
return "top" return "top"
} }

View File

@ -9,7 +9,8 @@
<meta property="og:image" th:content="${image}"> <meta property="og:image" th:content="${image}">
</head> </head>
<body> <body>
<h1 th:text="${applicationConfig.url + ' - Hideout'}">Hideout</h1> <h1 th:text="${instance.name + ' - Hideout'}">Hideout</h1>
<div><a href="/auth/sign_up"></a></div> <div><a href="/auth/sign_up" th:unless="${applicationConfig.private}">Sign up</a> <a href="/auth/sign_in">Sign in</a>
</div>
</body> </body>
</html> </html>