mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-03 12:30:19 +08:00
Move passwordType to org.
This commit is contained in:
@ -56,20 +56,22 @@ func CheckUserSignup(organization string, username string, password string, disp
|
||||
}
|
||||
|
||||
func checkPassword(user *User, password string) string {
|
||||
if user.PasswordType == "plain" {
|
||||
organization := getOrganization("admin", user.Owner)
|
||||
|
||||
if organization.PasswordType == "plain" {
|
||||
if password == user.Password {
|
||||
return ""
|
||||
} else {
|
||||
return "password incorrect"
|
||||
}
|
||||
} else if user.PasswordType == "salt" {
|
||||
} else if organization.PasswordType == "salt" {
|
||||
if getSaltedPassword(password) == user.Password {
|
||||
return ""
|
||||
} else {
|
||||
return "password incorrect"
|
||||
}
|
||||
} else {
|
||||
return fmt.Sprintf("unsupported password type: %s", user.PasswordType)
|
||||
return fmt.Sprintf("unsupported password type: %s", organization.PasswordType)
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,15 +81,15 @@ func CheckUserLogin(organization string, username string, password string) (*Use
|
||||
return nil, "the user does not exist, please sign up first"
|
||||
}
|
||||
|
||||
if user.IsForbidden {
|
||||
return nil, "the user is forbidden to sign in, please contact the administrator"
|
||||
}
|
||||
|
||||
msg := checkPassword(user, password)
|
||||
if msg != "" {
|
||||
return nil, msg
|
||||
}
|
||||
|
||||
if user.IsForbidden {
|
||||
return nil, "the user is forbidden to sign in, please contact the administrator"
|
||||
}
|
||||
|
||||
return user, ""
|
||||
}
|
||||
|
||||
|
@ -15,11 +15,12 @@ func initBuiltInOrganization() {
|
||||
}
|
||||
|
||||
organization = &Organization{
|
||||
Owner: "admin",
|
||||
Name: "built-in",
|
||||
CreatedTime: util.GetCurrentTime(),
|
||||
DisplayName: "Built-in Organization",
|
||||
WebsiteUrl: "https://example.com",
|
||||
Owner: "admin",
|
||||
Name: "built-in",
|
||||
CreatedTime: util.GetCurrentTime(),
|
||||
DisplayName: "Built-in Organization",
|
||||
WebsiteUrl: "https://example.com",
|
||||
PasswordType: "plain",
|
||||
}
|
||||
AddOrganization(organization)
|
||||
}
|
||||
@ -36,7 +37,6 @@ func initBuiltInUser() {
|
||||
CreatedTime: util.GetCurrentTime(),
|
||||
Id: util.GenerateId(),
|
||||
Password: "123",
|
||||
PasswordType: "plain",
|
||||
DisplayName: "Admin",
|
||||
Avatar: "https://casbin.org/img/casbin.svg",
|
||||
Email: "admin@example.com",
|
||||
|
@ -24,9 +24,10 @@ type Organization struct {
|
||||
Name string `xorm:"varchar(100) notnull pk" json:"name"`
|
||||
CreatedTime string `xorm:"varchar(100)" json:"createdTime"`
|
||||
|
||||
DisplayName string `xorm:"varchar(100)" json:"displayName"`
|
||||
WebsiteUrl string `xorm:"varchar(100)" json:"websiteUrl"`
|
||||
Favicon string `xorm:"varchar(100)" json:"favicon"`
|
||||
DisplayName string `xorm:"varchar(100)" json:"displayName"`
|
||||
WebsiteUrl string `xorm:"varchar(100)" json:"websiteUrl"`
|
||||
Favicon string `xorm:"varchar(100)" json:"favicon"`
|
||||
PasswordType string `xorm:"varchar(100)" json:"passwordType"`
|
||||
}
|
||||
|
||||
func GetOrganizations(owner string) []*Organization {
|
||||
|
@ -30,7 +30,6 @@ type User struct {
|
||||
Id string `xorm:"varchar(100)" json:"id"`
|
||||
Type string `xorm:"varchar(100)" json:"type"`
|
||||
Password string `xorm:"varchar(100)" json:"password"`
|
||||
PasswordType string `xorm:"varchar(100)" json:"passwordType"`
|
||||
DisplayName string `xorm:"varchar(100)" json:"displayName"`
|
||||
Avatar string `xorm:"varchar(255)" json:"avatar"`
|
||||
Email string `xorm:"varchar(100)" json:"email"`
|
||||
|
Reference in New Issue
Block a user