mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-02 19:40:19 +08:00
Check user under org.
This commit is contained in:
@ -28,16 +28,16 @@ func (user *User) getId() string {
|
||||
return fmt.Sprintf("%s/%s", user.Owner, user.Name)
|
||||
}
|
||||
|
||||
func HasMail(email string) string {
|
||||
user := GetMail(email)
|
||||
func HasMail(application *Application, email string) string {
|
||||
user := GetMail(application.Organization, email)
|
||||
if user != nil {
|
||||
return user.getId()
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func HasGithub(github string) string {
|
||||
user := GetGithub(github)
|
||||
func HasGithub(application *Application, github string) string {
|
||||
user := GetGithub(application.Organization, github)
|
||||
if user != nil {
|
||||
return user.getId()
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ type User struct {
|
||||
Email string `xorm:"varchar(100)" json:"email"`
|
||||
Phone string `xorm:"varchar(100)" json:"phone"`
|
||||
Affiliation string `xorm:"varchar(100)" json:"affiliation"`
|
||||
Tag string `xorm:"varchar(100)" json:"tag"`
|
||||
IsAdmin bool `json:"isAdmin"`
|
||||
|
||||
Github string `xorm:"varchar(100)" json:"github"`
|
||||
@ -119,8 +120,8 @@ func DeleteUser(user *User) bool {
|
||||
return affected != 0
|
||||
}
|
||||
|
||||
func GetMail(email string) *User {
|
||||
user := User{Email: email}
|
||||
func GetMail(organizationName string, email string) *User {
|
||||
user := User{Owner: organizationName, Email: email}
|
||||
existed, err := adapter.engine.Get(&user)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@ -133,8 +134,8 @@ func GetMail(email string) *User {
|
||||
}
|
||||
}
|
||||
|
||||
func GetGithub(github string) *User {
|
||||
user := User{Github: github}
|
||||
func GetGithub(organizationName string, github string) *User {
|
||||
user := User{Owner: organizationName, Github: github}
|
||||
existed, err := adapter.engine.Get(&user)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
Reference in New Issue
Block a user