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 {
if (cachedInstance != null) {
logger.trace("Use cache {}", cachedInstance)
@Suppress("UnsafeCallOnNullableType")
return cachedInstance!!
}

View File

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

View File

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