package handlers import ( "net/http" "strings" "github.com/gin-gonic/gin" "sproutgate-backend/internal/storage" ) // GetPublicRegistrationPolicy // @Summary 公开注册策略与 OAuth/Turnstile 开关 // @Tags public // @Produce json // @Success 200 {object} map[string]interface{} // @Router /api/public/registration-policy [get] func (h *Handler) GetPublicRegistrationPolicy(c *gin.Context) { h.store.MaybeSyncRuntimeConfigFromDB() o := h.store.PublicOAuthFlags() oc := h.store.GetOAuthConfig() tc := h.store.GetTurnstileConfig() c.JSON(http.StatusOK, gin.H{ "requireInviteCode": h.store.RegistrationRequireInvite(), "inviteRegisterRewardCoins": h.store.RegistrationInviteRegisterRewardCoins(), "selfServiceAccountMin": storage.MinSelfServiceAccountLen, "selfServiceAccountMax": storage.MaxSelfServiceAccountLen, "selfServiceAccountHint": "lowercase letters and digits only", "githubOAuthEnabled": o.GitHubEnabled, "giteaOAuthEnabled": o.GiteaEnabled, "googleOAuthEnabled": o.GoogleEnabled, "microsoftOAuthEnabled": o.MicrosoftEnabled, "linuxdoOAuthEnabled": o.LinuxdoEnabled, "githubOAuthLogoUrl": strings.TrimSpace(oc.GitHubLogoURL), "giteaOAuthLogoUrl": strings.TrimSpace(oc.GiteaLogoURL), "googleOAuthLogoUrl": strings.TrimSpace(oc.GoogleLogoURL), "microsoftOAuthLogoUrl": strings.TrimSpace(oc.MicrosoftLogoURL), "linuxdoOAuthLogoUrl": strings.TrimSpace(oc.LinuxdoLogoURL), "turnstileEnabled": tc.Enabled, "turnstileSiteKey": strings.TrimSpace(tc.SiteKey), }) }