Support private repo
This commit is contained in:
parent
d6dac160df
commit
33aa4f7438
13 changed files with 87 additions and 31 deletions
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue