feat: make Organization.EnableSoftDeletion and User.IsDeleted work (#3205)

* feat: make Organization.EnableSoftDeletion and User.IsDeleted work

* fix: add handling of the situation where organization is nil
This commit is contained in:
ZhaoYP 2001
2024-09-15 14:35:44 +08:00
committed by GitHub
parent e2ce9ad625
commit 0b17cb9746

View File

@ -950,7 +950,17 @@ func DeleteUser(user *User) (bool, error) {
return false, err
}
return deleteUser(user)
organization, err := GetOrganizationByUser(user)
if err != nil {
return false, err
}
if organization != nil && organization.EnableSoftDeletion {
user.IsDeleted = true
user.DeletedTime = util.GetCurrentTime()
return UpdateUser(user.GetId(), user, []string{"is_deleted", "deleted_time"}, false)
} else {
return deleteUser(user)
}
}
func GetUserInfo(user *User, scope string, aud string, host string) (*Userinfo, error) {