feat: implement the enforcement for new invitation page (#2628)

Added new invitation code implementation
This commit is contained in:
HGZ-20
2024-01-22 02:25:13 +08:00
committed by GitHub
parent de2932b5fb
commit d7c40459c0
30 changed files with 306 additions and 5 deletions

View File

@ -183,6 +183,8 @@ type User struct {
MfaPhoneEnabled bool `json:"mfaPhoneEnabled"`
MfaEmailEnabled bool `json:"mfaEmailEnabled"`
MultiFactorAuths []*MfaProps `xorm:"-" json:"multiFactorAuths,omitempty"`
Invitation string `xorm:"varchar(100) index" json:"invitation"`
InvitationCode string `xorm:"varchar(100) index" json:"invitationCode"`
Ldap string `xorm:"ldap varchar(100)" json:"ldap"`
Properties map[string]string `json:"properties"`
@ -496,6 +498,24 @@ func GetUserByUserIdOnly(userId string) (*User, error) {
}
}
func GetUserByInvitationCode(owner string, invitationCode string) (*User, error) {
if owner == "" || invitationCode == "" {
return nil, nil
}
user := User{Owner: owner, InvitationCode: invitationCode}
existed, err := ormer.Engine.Get(&user)
if err != nil {
return nil, err
}
if existed {
return &user, nil
} else {
return nil, nil
}
}
func GetUserByAccessKey(accessKey string) (*User, error) {
if accessKey == "" {
return nil, nil