diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/instance/GetLocalInstanceApplicationService.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/instance/GetLocalInstanceApplicationService.kt index b96b7e06..557737ed 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/instance/GetLocalInstanceApplicationService.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/instance/GetLocalInstanceApplicationService.kt @@ -19,7 +19,7 @@ class GetLocalInstanceApplicationService( transaction, logger ) { - var cachedInstance: Instance? = null + private var cachedInstance: Instance? = null override suspend fun internalExecute(command: Unit, principal: Principal): Instance { if (cachedInstance != null) { @@ -28,9 +28,9 @@ class GetLocalInstanceApplicationService( } val instance = ( - instanceRepository.findByUrl(applicationConfig.url.toURI()) - ?: throw InternalServerException("Local instance not found.") - ) + instanceRepository.findByUrl(applicationConfig.url.toURI()) + ?: throw InternalServerException("Local instance not found.") + ) cachedInstance = Instance.of(instance) @Suppress("UnsafeCallOnNullableType") diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/interfaces/api/auth/AuthController.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/interfaces/web/auth/AuthController.kt similarity index 80% rename from hideout-core/src/main/kotlin/dev/usbharu/hideout/core/interfaces/api/auth/AuthController.kt rename to hideout-core/src/main/kotlin/dev/usbharu/hideout/core/interfaces/web/auth/AuthController.kt index b19f3c4a..9b0d297b 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/interfaces/api/auth/AuthController.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/interfaces/web/auth/AuthController.kt @@ -14,13 +14,15 @@ * limitations under the License. */ -package dev.usbharu.hideout.core.interfaces.api.auth +package dev.usbharu.hideout.core.interfaces.web.auth import dev.usbharu.hideout.core.application.actor.RegisterLocalActor import dev.usbharu.hideout.core.application.actor.RegisterLocalActorApplicationService +import dev.usbharu.hideout.core.application.instance.GetLocalInstanceApplicationService import dev.usbharu.hideout.core.domain.model.support.principal.Anonymous import jakarta.servlet.http.HttpServletRequest import org.springframework.stereotype.Controller +import org.springframework.ui.Model import org.springframework.validation.annotation.Validated import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.ModelAttribute @@ -29,10 +31,14 @@ import org.springframework.web.bind.annotation.PostMapping @Controller class AuthController( private val registerLocalActorApplicationService: RegisterLocalActorApplicationService, + private val getLocalInstanceApplicationService: GetLocalInstanceApplicationService, ) { @GetMapping("/auth/sign_up") @Suppress("FunctionOnlyReturningConstant") - fun signUp(): String = "sign_up" + suspend fun signUp(model: Model): String { + model.addAttribute("instance", getLocalInstanceApplicationService.execute(Unit, Anonymous)) + return "sign_up" + } @PostMapping("/auth/sign_up") suspend fun signUp(@Validated @ModelAttribute signUpForm: SignUpForm, request: HttpServletRequest): String { diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/interfaces/api/auth/SignUpForm.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/interfaces/web/auth/SignUpForm.kt similarity index 68% rename from hideout-core/src/main/kotlin/dev/usbharu/hideout/core/interfaces/api/auth/SignUpForm.kt rename to hideout-core/src/main/kotlin/dev/usbharu/hideout/core/interfaces/web/auth/SignUpForm.kt index d70eb9c2..320187d8 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/interfaces/api/auth/SignUpForm.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/interfaces/web/auth/SignUpForm.kt @@ -1,4 +1,4 @@ -package dev.usbharu.hideout.core.interfaces.api.auth +package dev.usbharu.hideout.core.interfaces.web.auth data class SignUpForm( val username: String, diff --git a/hideout-core/src/main/resources/messages/hideout-web-messages.properties b/hideout-core/src/main/resources/messages/hideout-web-messages.properties index c22c2992..6a47f1b5 100644 --- a/hideout-core/src/main/resources/messages/hideout-web-messages.properties +++ b/hideout-core/src/main/resources/messages/hideout-web-messages.properties @@ -1,3 +1,6 @@ +auth-signUp.password=\u30D1\u30B9\u30EF\u30FC\u30C9 +auth-signUp.register=\u767B\u9332\u3059\u308B +auth-signUp.username=\u30E6\u30FC\u30B6\u30FC\u540D common.audio=\u30AA\u30FC\u30C7\u30A3\u30AA common.audio-download-link=\u97F3\u58F0\u30D5\u30A1\u30A4\u30EB\u3092\u30C0\u30A6\u30F3\u30ED\u30FC\u30C9 common.empty=\u8868\u793A\u3059\u308B\u3082\u306E\u304C\u3042\u308A\u307E\u305B\u3093 diff --git a/hideout-core/src/main/resources/messages/hideout-web-messages_en_US.properties b/hideout-core/src/main/resources/messages/hideout-web-messages_en_US.properties index f32efecd..f85b5d8a 100644 --- a/hideout-core/src/main/resources/messages/hideout-web-messages_en_US.properties +++ b/hideout-core/src/main/resources/messages/hideout-web-messages_en_US.properties @@ -1,3 +1,6 @@ +auth-signUp.password=Password +auth-signUp.register=Register Account +auth-signUp.username=Username common.audio=Audio common.audio-download-link=Download the audio. common.empty=Empty diff --git a/hideout-core/src/main/resources/messages/hideout-web-messages_ja_JP.properties b/hideout-core/src/main/resources/messages/hideout-web-messages_ja_JP.properties index c22c2992..6a47f1b5 100644 --- a/hideout-core/src/main/resources/messages/hideout-web-messages_ja_JP.properties +++ b/hideout-core/src/main/resources/messages/hideout-web-messages_ja_JP.properties @@ -1,3 +1,6 @@ +auth-signUp.password=\u30D1\u30B9\u30EF\u30FC\u30C9 +auth-signUp.register=\u767B\u9332\u3059\u308B +auth-signUp.username=\u30E6\u30FC\u30B6\u30FC\u540D common.audio=\u30AA\u30FC\u30C7\u30A3\u30AA common.audio-download-link=\u97F3\u58F0\u30D5\u30A1\u30A4\u30EB\u3092\u30C0\u30A6\u30F3\u30ED\u30FC\u30C9 common.empty=\u8868\u793A\u3059\u308B\u3082\u306E\u304C\u3042\u308A\u307E\u305B\u3093 diff --git a/hideout-core/src/main/resources/templates/sign_up.html b/hideout-core/src/main/resources/templates/sign_up.html index 63f57c5a..52d7abdd 100644 --- a/hideout-core/src/main/resources/templates/sign_up.html +++ b/hideout-core/src/main/resources/templates/sign_up.html @@ -2,13 +2,21 @@ - SignUp + Register Account + +
- - +
+ + +
+
+ + +