mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-09 01:13:41 +08:00
Speed up object.DoMigration()
This commit is contained in:
@ -22,20 +22,12 @@ import (
|
|||||||
type Migrator_1_314_0_PR_1841 struct{}
|
type Migrator_1_314_0_PR_1841 struct{}
|
||||||
|
|
||||||
func (*Migrator_1_314_0_PR_1841) IsMigrationNeeded() bool {
|
func (*Migrator_1_314_0_PR_1841) IsMigrationNeeded() bool {
|
||||||
users := []*User{}
|
count, err := adapter.Engine.Where("password_type=?", "").Count(&User{})
|
||||||
|
|
||||||
err := adapter.Engine.Table("user").Find(&users)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, u := range users {
|
return count > 100
|
||||||
if u.PasswordType != "" {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*Migrator_1_314_0_PR_1841) DoMigration() *migrate.Migration {
|
func (*Migrator_1_314_0_PR_1841) DoMigration() *migrate.Migration {
|
||||||
|
@ -554,6 +554,10 @@ func AddUser(user *User) (bool, error) {
|
|||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if user.PasswordType == "" && organization.PasswordType != "" {
|
||||||
|
user.PasswordType = organization.PasswordType
|
||||||
|
}
|
||||||
|
|
||||||
user.UpdateUserPassword(organization)
|
user.UpdateUserPassword(organization)
|
||||||
|
|
||||||
err = user.UpdateUserHash()
|
err = user.UpdateUserHash()
|
||||||
|
Reference in New Issue
Block a user