mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-03 12:30:19 +08:00
feat: support calling get-user API by only email, phone or userId without owner (#2398)
This commit is contained in:
@ -372,6 +372,24 @@ func GetUserByEmail(owner string, email string) (*User, error) {
|
||||
}
|
||||
}
|
||||
|
||||
func GetUserByEmailOnly(email string) (*User, error) {
|
||||
if email == "" {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
user := User{Email: email}
|
||||
existed, err := ormer.Engine.Get(&user)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if existed {
|
||||
return &user, nil
|
||||
} else {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
|
||||
func GetUserByPhone(owner string, phone string) (*User, error) {
|
||||
if owner == "" || phone == "" {
|
||||
return nil, nil
|
||||
@ -390,6 +408,24 @@ func GetUserByPhone(owner string, phone string) (*User, error) {
|
||||
}
|
||||
}
|
||||
|
||||
func GetUserByPhoneOnly(phone string) (*User, error) {
|
||||
if phone == "" {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
user := User{Phone: phone}
|
||||
existed, err := ormer.Engine.Get(&user)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if existed {
|
||||
return &user, nil
|
||||
} else {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
|
||||
func GetUserByUserId(owner string, userId string) (*User, error) {
|
||||
if owner == "" || userId == "" {
|
||||
return nil, nil
|
||||
|
Reference in New Issue
Block a user