mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-06 01:15:29 +08:00
25 lines
580 B
Go
25 lines
580 B
Go
package config
|
|
|
|
import (
|
|
"crypto/sha256"
|
|
"encoding/hex"
|
|
"strings"
|
|
)
|
|
|
|
func (a Account) Identifier() string {
|
|
if strings.TrimSpace(a.Email) != "" {
|
|
return strings.TrimSpace(a.Email)
|
|
}
|
|
if mobile := NormalizeMobileForStorage(a.Mobile); mobile != "" {
|
|
return mobile
|
|
}
|
|
// Backward compatibility: old configs may contain token-only accounts.
|
|
// Use a stable non-sensitive synthetic id so they can still join the pool.
|
|
token := strings.TrimSpace(a.Token)
|
|
if token == "" {
|
|
return ""
|
|
}
|
|
sum := sha256.Sum256([]byte(token))
|
|
return "token:" + hex.EncodeToString(sum[:8])
|
|
}
|