(c *gin.Context)
| 36 | } |
| 37 | |
| 38 | func UpdateOption(c *gin.Context) { |
| 39 | var option model.Option |
| 40 | err := json.NewDecoder(c.Request.Body).Decode(&option) |
| 41 | if err != nil { |
| 42 | c.JSON(http.StatusBadRequest, gin.H{ |
| 43 | "success": false, |
| 44 | "message": "无效的参数", |
| 45 | }) |
| 46 | return |
| 47 | } |
| 48 | switch option.Key { |
| 49 | case "GitHubOAuthEnabled": |
| 50 | if option.Value == "true" && common.GitHubClientId == "" { |
| 51 | c.JSON(http.StatusOK, gin.H{ |
| 52 | "success": false, |
| 53 | "message": "无法启用 GitHub OAuth,请先填入 GitHub Client Id 以及 GitHub Client Secret!", |
| 54 | }) |
| 55 | return |
| 56 | } |
| 57 | case "oidc.enabled": |
| 58 | if option.Value == "true" && system_setting.GetOIDCSettings().ClientId == "" { |
| 59 | c.JSON(http.StatusOK, gin.H{ |
| 60 | "success": false, |
| 61 | "message": "无法启用 OIDC 登录,请先填入 OIDC Client Id 以及 OIDC Client Secret!", |
| 62 | }) |
| 63 | return |
| 64 | } |
| 65 | case "LinuxDOOAuthEnabled": |
| 66 | if option.Value == "true" && common.LinuxDOClientId == "" { |
| 67 | c.JSON(http.StatusOK, gin.H{ |
| 68 | "success": false, |
| 69 | "message": "无法启用 LinuxDO OAuth,请先填入 LinuxDO Client Id 以及 LinuxDO Client Secret!", |
| 70 | }) |
| 71 | return |
| 72 | } |
| 73 | case "EmailDomainRestrictionEnabled": |
| 74 | if option.Value == "true" && len(common.EmailDomainWhitelist) == 0 { |
| 75 | c.JSON(http.StatusOK, gin.H{ |
| 76 | "success": false, |
| 77 | "message": "无法启用邮箱域名限制,请先填入限制的邮箱域名!", |
| 78 | }) |
| 79 | return |
| 80 | } |
| 81 | case "WeChatAuthEnabled": |
| 82 | if option.Value == "true" && common.WeChatServerAddress == "" { |
| 83 | c.JSON(http.StatusOK, gin.H{ |
| 84 | "success": false, |
| 85 | "message": "无法启用微信登录,请先填入微信登录相关配置信息!", |
| 86 | }) |
| 87 | return |
| 88 | } |
| 89 | case "TurnstileCheckEnabled": |
| 90 | if option.Value == "true" && common.TurnstileSiteKey == "" { |
| 91 | c.JSON(http.StatusOK, gin.H{ |
| 92 | "success": false, |
| 93 | "message": "无法启用 Turnstile 校验,请先填入 Turnstile 校验相关配置信息!", |
| 94 | }) |
| 95 |
nothing calls this directly
no test coverage detected