mirror of
https://github.com/casdoor/casdoor.git
synced 2025-09-07 02:20:28 +08:00
feat: support e164 phone number in GetUserByPhone() (#4099)
This commit is contained in:
@@ -30,6 +30,7 @@ import (
|
||||
"unicode"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/nyaruka/phonenumbers"
|
||||
)
|
||||
|
||||
func ParseInt(s string) int {
|
||||
@@ -278,6 +279,19 @@ func GetMaskedPhone(phone string) string {
|
||||
return rePhone.ReplaceAllString(phone, "$1****$2")
|
||||
}
|
||||
|
||||
func GetSeperatedPhone(phone string) string {
|
||||
if strings.HasPrefix(phone, "+") {
|
||||
phoneNumberParsed, err := phonenumbers.Parse(phone, "")
|
||||
if err != nil {
|
||||
return phone
|
||||
}
|
||||
|
||||
phone = fmt.Sprintf("%d", phoneNumberParsed.GetNationalNumber())
|
||||
}
|
||||
|
||||
return phone
|
||||
}
|
||||
|
||||
func GetMaskedEmail(email string) string {
|
||||
if email == "" {
|
||||
return ""
|
||||
|
Reference in New Issue
Block a user