Add debug mode for cfturnstile
Signed-off-by: Asai Neko <sugar@sne.moe>
This commit is contained in:
@@ -36,9 +36,14 @@ type MagicResult struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *AuthServiceImpl) Magic(payload *MagicPayload) (result *MagicResult) {
|
func (self *AuthServiceImpl) Magic(payload *MagicPayload) (result *MagicResult) {
|
||||||
|
var ok bool
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
ok, err := turnstile.VerifyTurnstile(payload.Data.TurnstileToken, payload.Data.ClientIP)
|
if viper.GetBool("server.debug_mode") {
|
||||||
|
goto BypassCfTurnstile
|
||||||
|
}
|
||||||
|
|
||||||
|
ok, err = turnstile.VerifyTurnstile(payload.Data.TurnstileToken, payload.Data.ClientIP)
|
||||||
if err != nil || !ok {
|
if err != nil || !ok {
|
||||||
exception := new(exception.Builder).
|
exception := new(exception.Builder).
|
||||||
SetStatus(exception.StatusUser).
|
SetStatus(exception.StatusUser).
|
||||||
@@ -60,6 +65,7 @@ func (self *AuthServiceImpl) Magic(payload *MagicPayload) (result *MagicResult)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BypassCfTurnstile:
|
||||||
code, err := authcode.NewAuthCode(payload.Context, payload.Data.ClientId, payload.Data.Email)
|
code, err := authcode.NewAuthCode(payload.Context, payload.Data.ClientId, payload.Data.Email)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
exception := new(exception.Builder).
|
exception := new(exception.Builder).
|
||||||
|
|||||||
Reference in New Issue
Block a user