diff --git a/.gitignore b/.gitignore index 25c21d6b..05ba5a3e 100644 --- a/.gitignore +++ b/.gitignore @@ -29,4 +29,6 @@ lastupdate.tmp commentsRouter*.go # ignore build result -casdoor \ No newline at end of file +casdoor +server_linux_arm64 +server_linux_amd64 diff --git a/controllers/application.go b/controllers/application.go index d4450d00..8cd31ca5 100644 --- a/controllers/application.go +++ b/controllers/application.go @@ -118,8 +118,7 @@ func (c *ApiController) GetOrganizationApplications() { } if limit == "" || page == "" { - var applications []*object.Application - applications = object.GetOrganizationApplications(owner, organization) + applications := object.GetOrganizationApplications(owner, organization) c.Data["json"] = object.GetMaskedApplications(applications, userId) c.ServeJSON() } else { diff --git a/controllers/chat.go b/controllers/chat.go index 52c0b444..f501966d 100644 --- a/controllers/chat.go +++ b/controllers/chat.go @@ -30,8 +30,7 @@ import ( // @Success 200 {array} object.Chat The Response object // @router /get-chats [get] func (c *ApiController) GetChats() { - owner := c.Input().Get("owner") - owner = "admin" + owner := "admin" limit := c.Input().Get("pageSize") page := c.Input().Get("p") field := c.Input().Get("field") diff --git a/idp/wecom_third_party.go b/idp/wecom_third_party.go index e0e66579..ff19c099 100644 --- a/idp/wecom_third_party.go +++ b/idp/wecom_third_party.go @@ -75,7 +75,9 @@ func (idp *WeComIdProvider) GetToken(code string) (*oauth2.Token, error) { ProviderSecret string `json:"provider_secret"` }{idp.Config.ClientID, idp.Config.ClientSecret} data, err := idp.postWithBody(pTokenParams, "https://qyapi.weixin.qq.com/cgi-bin/service/get_provider_token") - + if err != nil { + return nil, err + } pToken := &WeComProviderToken{} err = json.Unmarshal(data, pToken) if err != nil { diff --git a/main.go b/main.go index 497b56ec..1b202250 100644 --- a/main.go +++ b/main.go @@ -27,7 +27,6 @@ import ( "github.com/casdoor/casdoor/object" "github.com/casdoor/casdoor/proxy" "github.com/casdoor/casdoor/routers" - _ "github.com/casdoor/casdoor/routers" "github.com/casdoor/casdoor/util" ) diff --git a/object/application.go b/object/application.go index 79d8e3b9..3e06bbc5 100644 --- a/object/application.go +++ b/object/application.go @@ -145,7 +145,7 @@ func getProviderMap(owner string) map[string]*Provider { m := map[string]*Provider{} for _, provider := range providers { // Get QRCode only once - if provider.Type == "WeChat" && provider.DisableSsl == true && provider.Content == "" { + if provider.Type == "WeChat" && provider.DisableSsl && provider.Content == "" { provider.Content, _ = idp.GetWechatOfficialAccountQRCode(provider.ClientId2, provider.ClientSecret2) UpdateProvider(provider.Owner+"/"+provider.Name, provider) } diff --git a/object/check.go b/object/check.go index aeffbf51..07cbf46a 100644 --- a/object/check.go +++ b/object/check.go @@ -248,7 +248,7 @@ func CheckUserPassword(organization string, username string, password string, la enableCaptcha = options[0] } user := GetUserByFields(organization, username) - if user == nil || user.IsDeleted == true { + if user == nil || user.IsDeleted { return nil, fmt.Sprintf(i18n.Translate(lang, "general:The user: %s doesn't exist"), util.GetId(organization, username)) } diff --git a/object/migrator_1_235_0_PR_1530.go b/object/migrator_1_235_0_PR_1530.go index ad67b888..3604e5d3 100644 --- a/object/migrator_1_235_0_PR_1530.go +++ b/object/migrator_1_235_0_PR_1530.go @@ -25,10 +25,7 @@ type Migrator_1_235_0_PR_1530 struct{} func (*Migrator_1_235_0_PR_1530) IsMigrationNeeded() bool { exist, _ := adapter.Engine.IsTableExist("casbin_rule") - if exist { - return true - } - return false + return exist } func (*Migrator_1_235_0_PR_1530) DoMigration() *migrate.Migration { diff --git a/object/oidc_discovery.go b/object/oidc_discovery.go index dacd0c2c..d99986c8 100644 --- a/object/oidc_discovery.go +++ b/object/oidc_discovery.go @@ -55,13 +55,8 @@ func isIpAddress(host string) bool { // Attempt to parse the host as an IP address (both IPv4 and IPv6) ip := net.ParseIP(hostWithoutPort) - if ip != nil { - // The host is an IP address - return true - } - - // The host is not an IP address - return false + // if host is not nil is an IP address else is not an IP address + return ip != nil } func getOriginFromHost(host string) (string, string) { diff --git a/object/verification.go b/object/verification.go index 6e63f8a0..8225f823 100644 --- a/object/verification.go +++ b/object/verification.go @@ -33,10 +33,10 @@ type VerifyResult struct { } const ( - VerificationSuccess int = 0 - wrongCodeError = 1 - noRecordError = 2 - timeoutError = 3 + VerificationSuccess = iota + wrongCodeError + noRecordError + timeoutError ) const ( diff --git a/sync/database_canal.go b/sync/database_canal.go index 927c6b61..d79d34d1 100644 --- a/sync/database_canal.go +++ b/sync/database_canal.go @@ -66,13 +66,13 @@ func (db *Database) OnRow(e *canal.RowsEvent) error { for i, row := range e.Rows { for j, item := range row { if i%2 == 0 { - if isChar[j] == true { + if isChar[j] { oldColumnValue[j] = fmt.Sprintf("%s", item) } else { oldColumnValue[j] = fmt.Sprintf("%d", item) } } else { - if isChar[j] == true { + if isChar[j] { if item == nil { newColumnValue[j] = nil } else { @@ -103,7 +103,7 @@ func (db *Database) OnRow(e *canal.RowsEvent) error { db.engine.Exec("BEGIN") for _, row := range e.Rows { for j, item := range row { - if isChar[j] == true { + if isChar[j] { oldColumnValue[j] = fmt.Sprintf("%s", item) } else { oldColumnValue[j] = fmt.Sprintf("%d", item) @@ -128,7 +128,7 @@ func (db *Database) OnRow(e *canal.RowsEvent) error { db.engine.Exec("BEGIN") for _, row := range e.Rows { for j, item := range row { - if isChar[j] == true { + if isChar[j] { if item == nil { newColumnValue[j] = nil } else { diff --git a/util/validation.go b/util/validation.go index 70a1eae8..e8675a87 100644 --- a/util/validation.go +++ b/util/validation.go @@ -25,7 +25,7 @@ import ( var rePhone *regexp.Regexp func init() { - rePhone, _ = regexp.Compile("(\\d{3})\\d*(\\d{4})") + rePhone, _ = regexp.Compile(`(\d{3})\d*(\d{4})`) } func IsEmailValid(email string) bool {