mirror of https://github.com/usbharu/Hideout.git
feat: 登録不可時にHTMLでsubmitできないように
This commit is contained in:
parent
9327bb0372
commit
5b322ade29
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
package dev.usbharu.hideout.core.interfaces.api.auth
|
package dev.usbharu.hideout.core.interfaces.api.auth
|
||||||
|
|
||||||
|
import dev.usbharu.hideout.application.config.ApplicationConfig
|
||||||
|
import dev.usbharu.hideout.application.config.CaptchaConfig
|
||||||
import dev.usbharu.hideout.core.service.auth.AuthApiService
|
import dev.usbharu.hideout.core.service.auth.AuthApiService
|
||||||
import dev.usbharu.hideout.core.service.auth.RegisterAccountDto
|
import dev.usbharu.hideout.core.service.auth.RegisterAccountDto
|
||||||
import org.springframework.stereotype.Controller
|
import org.springframework.stereotype.Controller
|
||||||
|
@ -26,10 +28,17 @@ import org.springframework.web.bind.annotation.ModelAttribute
|
||||||
import org.springframework.web.bind.annotation.PostMapping
|
import org.springframework.web.bind.annotation.PostMapping
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
class AuthController(private val authApiService: AuthApiService) {
|
class AuthController(
|
||||||
|
private val authApiService: AuthApiService,
|
||||||
|
private val captchaConfig: CaptchaConfig,
|
||||||
|
private val applicationConfig: ApplicationConfig
|
||||||
|
) {
|
||||||
@GetMapping("/auth/sign_up")
|
@GetMapping("/auth/sign_up")
|
||||||
@Suppress("FunctionOnlyReturningConstant")
|
fun signUp(model: Model): String {
|
||||||
fun signUp(): String = "sign_up"
|
model.addAttribute("siteKey", captchaConfig.reCaptchaSiteKey)
|
||||||
|
model.addAttribute("applicationConfig", applicationConfig)
|
||||||
|
return "sign_up"
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/auth/sign_up")
|
@PostMapping("/auth/sign_up")
|
||||||
suspend fun signUp(@Validated @ModelAttribute signUpForm: SignUpForm, model: Model): String {
|
suspend fun signUp(@Validated @ModelAttribute signUpForm: SignUpForm, model: Model): String {
|
||||||
|
@ -41,6 +50,6 @@ class AuthController(private val authApiService: AuthApiService) {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
return "redirect:"+registerAccount.first.url
|
return "redirect:" + registerAccount.url
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<form method='post' th:action="@{/auth/sign_up}">
|
<form method='post' th:action="@{/auth/sign_up}" th:disabled="${applicationConfig.private}">
|
||||||
<input name='username' type='text' value=''>
|
<input name='username' type='text' value=''>
|
||||||
<input name='password' type='password'>
|
<input name='password' type='password'>
|
||||||
<input type="hidden" name="recaptchaResponse" id="recaptchaResponse">
|
<input type="hidden" name="recaptchaResponse" id="recaptchaResponse">
|
||||||
|
|
Loading…
Reference in New Issue