mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-04 05:10:19 +08:00
refactor: code-optimization (#1885)
* refactor: code-optimization * fix: restoring code style * fix: gofmt
This commit is contained in:
@ -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)
|
||||
}
|
||||
|
@ -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))
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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) {
|
||||
|
@ -33,10 +33,10 @@ type VerifyResult struct {
|
||||
}
|
||||
|
||||
const (
|
||||
VerificationSuccess int = 0
|
||||
wrongCodeError = 1
|
||||
noRecordError = 2
|
||||
timeoutError = 3
|
||||
VerificationSuccess = iota
|
||||
wrongCodeError
|
||||
noRecordError
|
||||
timeoutError
|
||||
)
|
||||
|
||||
const (
|
||||
|
Reference in New Issue
Block a user