fix #644
This commit is contained in:
parent
ef275ebf62
commit
8ea7ba3afa
|
@ -77,6 +77,17 @@ func (org *User) RemoveMember(uid int64) error {
|
||||||
return RemoveOrgUser(org.Id, uid)
|
return RemoveOrgUser(org.Id, uid)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsOrgEmailUsed returns true if the e-mail has been used in organization account.
|
||||||
|
func IsOrgEmailUsed(email string) (bool, error) {
|
||||||
|
if len(email) == 0 {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
return x.Get(&User{
|
||||||
|
Email: email,
|
||||||
|
Type: ORGANIZATION,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// CreateOrganization creates record of a new organization.
|
// CreateOrganization creates record of a new organization.
|
||||||
func CreateOrganization(org, owner *User) (*User, error) {
|
func CreateOrganization(org, owner *User) (*User, error) {
|
||||||
if !IsLegalName(org.Name) {
|
if !IsLegalName(org.Name) {
|
||||||
|
@ -90,7 +101,7 @@ func CreateOrganization(org, owner *User) (*User, error) {
|
||||||
return nil, ErrUserAlreadyExist
|
return nil, ErrUserAlreadyExist
|
||||||
}
|
}
|
||||||
|
|
||||||
isExist, err = IsEmailUsed(org.Email)
|
isExist, err = IsOrgEmailUsed(org.Email)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if isExist {
|
} else if isExist {
|
||||||
|
|
|
@ -53,12 +53,12 @@ type User struct {
|
||||||
LowerName string `xorm:"UNIQUE NOT NULL"`
|
LowerName string `xorm:"UNIQUE NOT NULL"`
|
||||||
Name string `xorm:"UNIQUE NOT NULL"`
|
Name string `xorm:"UNIQUE NOT NULL"`
|
||||||
FullName string
|
FullName string
|
||||||
Email string `xorm:"UNIQUE NOT NULL"`
|
Email string `xorm:"UNIQUE(s) NOT NULL"`
|
||||||
Passwd string `xorm:"NOT NULL"`
|
Passwd string `xorm:"NOT NULL"`
|
||||||
LoginType LoginType
|
LoginType LoginType
|
||||||
LoginSource int64 `xorm:"NOT NULL DEFAULT 0"`
|
LoginSource int64 `xorm:"NOT NULL DEFAULT 0"`
|
||||||
LoginName string
|
LoginName string
|
||||||
Type UserType
|
Type UserType `xorm:"UNIQUE(s)"`
|
||||||
Orgs []*User `xorm:"-"`
|
Orgs []*User `xorm:"-"`
|
||||||
Repos []*Repository `xorm:"-"`
|
Repos []*Repository `xorm:"-"`
|
||||||
Location string
|
Location string
|
||||||
|
|
Loading…
Reference in New Issue