mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-03 20:50:19 +08:00
Add user.refreshAvatar()
This commit is contained in:
@ -16,6 +16,7 @@ package object
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/casdoor/casdoor/proxy"
|
||||
@ -37,3 +38,22 @@ func TestSyncPermanentAvatars(t *testing.T) {
|
||||
fmt.Printf("[%d/%d]: Update user: [%s]'s permanent avatar: %s\n", i, len(users), user.GetId(), user.PermanentAvatar)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUpdateAvatars(t *testing.T) {
|
||||
InitConfig()
|
||||
InitDefaultStorageProvider()
|
||||
proxy.InitHttpClient()
|
||||
|
||||
users := GetUsers("casdoor")
|
||||
for _, user := range users {
|
||||
if strings.HasPrefix(user.Avatar, "http") {
|
||||
continue
|
||||
}
|
||||
|
||||
updated := user.refreshAvatar()
|
||||
if updated {
|
||||
user.PermanentAvatar = "*"
|
||||
UpdateUser(user.GetId(), user, []string{"avatar"}, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user