diff --git a/captcha/provider.go b/captcha/provider.go index b9635e87..fe652d42 100644 --- a/captcha/provider.go +++ b/captcha/provider.go @@ -21,19 +21,21 @@ type CaptchaProvider interface { } func GetCaptchaProvider(captchaType string) CaptchaProvider { - if captchaType == "Default" { + switch captchaType { + case "Default": return NewDefaultCaptchaProvider() - } else if captchaType == "reCAPTCHA" { + case "reCAPTCHA": return NewReCaptchaProvider() - } else if captchaType == "hCaptcha" { - return NewHCaptchaProvider() - } else if captchaType == "Aliyun Captcha" { + case "Aliyun Captcha": return NewAliyunCaptchaProvider() - } else if captchaType == "GEETEST" { + case "hCaptcha": + return NewHCaptchaProvider() + case "GEETEST": return NewGEETESTCaptchaProvider() - } else if captchaType == "Cloudflare Turnstile" { + case "Cloudflare Turnstile": return NewCloudflareTurnstileProvider() } + return nil } diff --git a/controllers/ldap.go b/controllers/ldap.go index d89b1ecb..b21364a9 100644 --- a/controllers/ldap.go +++ b/controllers/ldap.go @@ -51,7 +51,7 @@ type LdapSyncResp struct { func (c *ApiController) GetLdapUser() { ldapServer := LdapServer{} err := json.Unmarshal(c.Ctx.Input.RequestBody, &ldapServer) - if err != nil || util.IsStrsEmpty(ldapServer.Host, ldapServer.Admin, ldapServer.Passwd, ldapServer.BaseDn) { + if err != nil || util.IsStringsEmpty(ldapServer.Host, ldapServer.Admin, ldapServer.Passwd, ldapServer.BaseDn) { c.ResponseError(c.T("general:Missing parameter")) return } @@ -119,7 +119,7 @@ func (c *ApiController) GetLdaps() { func (c *ApiController) GetLdap() { id := c.Input().Get("id") - if util.IsStrsEmpty(id) { + if util.IsStringsEmpty(id) { c.ResponseError(c.T("general:Missing parameter")) return } @@ -140,7 +140,7 @@ func (c *ApiController) AddLdap() { return } - if util.IsStrsEmpty(ldap.Owner, ldap.ServerName, ldap.Host, ldap.Admin, ldap.Passwd, ldap.BaseDn) { + if util.IsStringsEmpty(ldap.Owner, ldap.ServerName, ldap.Host, ldap.Admin, ldap.Passwd, ldap.BaseDn) { c.ResponseError(c.T("general:Missing parameter")) return } @@ -170,7 +170,7 @@ func (c *ApiController) AddLdap() { func (c *ApiController) UpdateLdap() { var ldap object.Ldap err := json.Unmarshal(c.Ctx.Input.RequestBody, &ldap) - if err != nil || util.IsStrsEmpty(ldap.Owner, ldap.ServerName, ldap.Host, ldap.Admin, ldap.Passwd, ldap.BaseDn) { + if err != nil || util.IsStringsEmpty(ldap.Owner, ldap.ServerName, ldap.Host, ldap.Admin, ldap.Passwd, ldap.BaseDn) { c.ResponseError(c.T("general:Missing parameter")) return } diff --git a/controllers/service.go b/controllers/service.go index 209114d0..cd96eb57 100644 --- a/controllers/service.go +++ b/controllers/service.go @@ -80,7 +80,7 @@ func (c *ApiController) SendEmail() { c.ResponseOk() } - if util.IsStrsEmpty(emailForm.Title, emailForm.Content, emailForm.Sender) { + if util.IsStringsEmpty(emailForm.Title, emailForm.Content, emailForm.Sender) { c.ResponseError(fmt.Sprintf(c.T("service:Empty parameters for emailForm: %v"), emailForm)) return } diff --git a/controllers/verification.go b/controllers/verification.go index 26cec533..e42306f5 100644 --- a/controllers/verification.go +++ b/controllers/verification.go @@ -177,7 +177,7 @@ func (c *ApiController) ResetEmailOrPhone() { dest := c.Ctx.Request.Form.Get("dest") code := c.Ctx.Request.Form.Get("code") - if util.IsStrsEmpty(destType, dest, code) { + if util.IsStringsEmpty(destType, dest, code) { c.ResponseError(c.T("general:Missing parameter")) return } diff --git a/object/ldap.go b/object/ldap.go index 4e2bd062..52384597 100644 --- a/object/ldap.go +++ b/object/ldap.go @@ -329,7 +329,7 @@ func GetLdaps(owner string) []*Ldap { } func GetLdap(id string) *Ldap { - if util.IsStrsEmpty(id) { + if util.IsStringsEmpty(id) { return nil } diff --git a/object/verification.go b/object/verification.go index 0a29b507..5745d8bf 100644 --- a/object/verification.go +++ b/object/verification.go @@ -122,11 +122,8 @@ func AddToVerificationRecord(user *User, provider *Provider, remoteAddr, recordT record.Owner = provider.Owner record.Name = util.GenerateId() record.CreatedTime = util.GetCurrentTime() - if user != nil { - record.User = user.GetId() - } - record.Provider = provider.Name + record.Provider = provider.Name record.Receiver = dest record.Code = code record.Time = time.Now().Unix() diff --git a/util/string.go b/util/string.go index 8d51c984..a38a80ed 100644 --- a/util/string.go +++ b/util/string.go @@ -145,7 +145,7 @@ func GetMd5Hash(text string) string { return hex.EncodeToString(hash[:]) } -func IsStrsEmpty(strs ...string) bool { +func IsStringsEmpty(strs ...string) bool { for _, str := range strs { if len(str) == 0 { return true diff --git a/util/string_test.go b/util/string_test.go index 0bd75c66..720dbba8 100644 --- a/util/string_test.go +++ b/util/string_test.go @@ -183,7 +183,7 @@ func TestIsStrsEmpty(t *testing.T) { } for _, scenery := range scenarios { t.Run(scenery.description, func(t *testing.T) { - actual := IsStrsEmpty(scenery.input...) + actual := IsStringsEmpty(scenery.input...) assert.Equal(t, scenery.expected, actual, "The returned value not is expected") }) } diff --git a/web/src/common/SamlWidget.js b/web/src/common/SamlWidget.js index 2aed9f53..ebfd091d 100644 --- a/web/src/common/SamlWidget.js +++ b/web/src/common/SamlWidget.js @@ -1,3 +1,17 @@ +// Copyright 2022 The Casdoor Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + import React from "react"; import {Col, Row} from "antd"; import * as Setting from "../Setting";