From 43496ecda77ff322d190b90eeb74ee0ba9c833a1 Mon Sep 17 00:00:00 2001 From: ckt1031 <65409152+ckt1031@users.noreply.github.com> Date: Tue, 8 Aug 2023 23:14:48 +0800 Subject: [PATCH] feat: add turnstile in account deletion --- router/api-router.go | 2 +- web/src/components/PersonalSetting.js | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/router/api-router.go b/router/api-router.go index 8bb31f8e..dad417b1 100644 --- a/router/api-router.go +++ b/router/api-router.go @@ -38,7 +38,7 @@ func SetApiRouter(router *gin.Engine) { { selfRoute.GET("/self", controller.GetSelf) selfRoute.PUT("/self", controller.UpdateSelf) - selfRoute.DELETE("/self", controller.DeleteSelf) + selfRoute.DELETE("/self", middleware.TurnstileCheck(), controller.DeleteSelf) selfRoute.GET("/token", controller.GenerateAccessToken) selfRoute.GET("/aff", controller.GetAffCode) selfRoute.POST("/topup", controller.TopUp) diff --git a/web/src/components/PersonalSetting.js b/web/src/components/PersonalSetting.js index 90b2e13d..e81df700 100644 --- a/web/src/components/PersonalSetting.js +++ b/web/src/components/PersonalSetting.js @@ -170,9 +170,13 @@ const PersonalSetting = () => { const bindEmail = async () => { if (inputs.email_verification_code === '') return; + if (turnstileEnabled && turnstileToken === '') { + showInfo('请稍后几秒重试,Turnstile 正在检查用户环境!'); + return; + } setLoading(true); const res = await API.get( - `/api/oauth/email/bind?email=${inputs.email}&code=${inputs.email_verification_code}` + `/api/oauth/email/bind?email=${inputs.email}&code=${inputs.email_verification_code}&turnstile=${turnstileToken}` ); const { success, message } = res.data; if (success) { @@ -374,6 +378,16 @@ const PersonalSetting = () => { ) : ( <> )} + {turnstileEnabled ? ( + { + setTurnstileToken(token); + }} + /> + ) : ( + <> + )}