diff options
author | 无闻 <joe2010xtmf@163.com> | 2014-04-07 15:47:26 -0400 |
---|---|---|
committer | 无闻 <joe2010xtmf@163.com> | 2014-04-07 15:47:26 -0400 |
commit | 2577940c30f6a6d15390974ab36f8c3d1e00f9f4 (patch) | |
tree | c5f8fac19903327e78d5ac4f0fa2f8004a10974d /models/access.go | |
parent | ef6b9784962d3152d3ec46833303bad72915af57 (diff) | |
parent | 22feddf804c7fbf3418cbbc8e7302da271da4e5a (diff) |
Merge pull request #68 from gogits/dev
Dev
Diffstat (limited to 'models/access.go')
-rw-r--r-- | models/access.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/models/access.go b/models/access.go index 83261575..2c090015 100644 --- a/models/access.go +++ b/models/access.go @@ -7,6 +7,8 @@ package models import ( "strings" "time" + + "github.com/lunny/xorm" ) // Access types. @@ -40,6 +42,15 @@ func UpdateAccess(access *Access) error { return err } +// UpdateAccess updates access information with session for rolling back. +func UpdateAccessWithSession(sess *xorm.Session, access *Access) error { + if _, err := sess.Id(access.Id).Update(access); err != nil { + sess.Rollback() + return err + } + return nil +} + // 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{ |