diff options
Diffstat (limited to 'models')
-rw-r--r-- | models/access.go | 15 | ||||
-rw-r--r-- | models/user.go | 3 |
2 files changed, 14 insertions, 4 deletions
diff --git a/models/access.go b/models/access.go index 2c0900151f..5bf93f1b1b 100644 --- a/models/access.go +++ b/models/access.go @@ -53,10 +53,17 @@ func UpdateAccessWithSession(sess *xorm.Session, access *Access) error { // HasAccess returns true if someone can read or write to given repository. func HasAccess(userName, repoName string, mode int) (bool, error) { - return orm.Get(&Access{ - Id: 0, + access := &Access{ UserName: strings.ToLower(userName), RepoName: strings.ToLower(repoName), - Mode: mode, - }) + } + has, err := orm.Get(access) + if err != nil { + return false, err + } else if !has { + return false, nil + } else if mode > access.Mode { + return false, nil + } + return true, nil } diff --git a/models/user.go b/models/user.go index 5274970fa0..ea2c79b771 100644 --- a/models/user.go +++ b/models/user.go @@ -295,6 +295,9 @@ func DeleteUser(user *User) error { } // Delete oauth2. + if _, err = orm.Delete(&Oauth2{Uid: user.Id}); err != nil { + return err + } // Delete all feeds. if _, err = orm.Delete(&Action{UserId: user.Id}); err != nil { |