summaryrefslogtreecommitdiffstats
path: root/models/org.go
diff options
context:
space:
mode:
authorUnknwon <joe2010xtmf@163.com>2014-11-21 13:10:00 -0500
committerUnknwon <joe2010xtmf@163.com>2014-11-21 13:10:00 -0500
commit8ea7ba3afa686303f6597f6244bd9280f0b69a23 (patch)
treee8149eea899d02682519fa2855b72321ef3eeace /models/org.go
parentef275ebf62608b1bd2c7e48862e723cd822d93c2 (diff)
downloadgitea-8ea7ba3afa686303f6597f6244bd9280f0b69a23.tar.gz
gitea-8ea7ba3afa686303f6597f6244bd9280f0b69a23.zip
fix #644
Diffstat (limited to 'models/org.go')
-rw-r--r--models/org.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/models/org.go b/models/org.go
index 3232bf2ac1..90e5a1f3a0 100644
--- a/models/org.go
+++ b/models/org.go
@@ -77,6 +77,17 @@ func (org *User) RemoveMember(uid int64) error {
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.
func CreateOrganization(org, owner *User) (*User, error) {
if !IsLegalName(org.Name) {
@@ -90,7 +101,7 @@ func CreateOrganization(org, owner *User) (*User, error) {
return nil, ErrUserAlreadyExist
}
- isExist, err = IsEmailUsed(org.Email)
+ isExist, err = IsOrgEmailUsed(org.Email)
if err != nil {
return nil, err
} else if isExist {