mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-08-03 09:52:26 +02:00
Add postgres support, clean code, code review
This commit is contained in:
parent
9d3b003add
commit
e51afe4621
19 changed files with 1124 additions and 303 deletions
|
@ -9,11 +9,13 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
// Access types.
|
||||
const (
|
||||
AU_READABLE = iota + 1
|
||||
AU_WRITABLE
|
||||
)
|
||||
|
||||
// Access represents the accessibility of user and repository.
|
||||
type Access struct {
|
||||
Id int64
|
||||
UserName string `xorm:"unique(s)"`
|
||||
|
@ -22,12 +24,13 @@ type Access struct {
|
|||
Created time.Time `xorm:"created"`
|
||||
}
|
||||
|
||||
// AddAccess adds new access record.
|
||||
func AddAccess(access *Access) error {
|
||||
_, err := orm.Insert(access)
|
||||
return err
|
||||
}
|
||||
|
||||
// if one user can read or write one repository
|
||||
// HasAccess returns true if someone can read or write given repository.
|
||||
func HasAccess(userName, repoName string, mode int) (bool, error) {
|
||||
return orm.Get(&Access{
|
||||
Id: 0,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue