mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-05-20 14:00:04 +02:00
add publickey & access
This commit is contained in:
parent
b1c5adc2f2
commit
ee9bcf4d9f
4 changed files with 87 additions and 15 deletions
29
models/access.go
Normal file
29
models/access.go
Normal file
|
@ -0,0 +1,29 @@
|
|||
package models
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
Readable = iota + 1
|
||||
Writable
|
||||
)
|
||||
|
||||
type Access struct {
|
||||
Id int64
|
||||
UserName string `xorm:"unique(s)"`
|
||||
RepoName string `xorm:"unique(s)"`
|
||||
Mode int `xorm:"unique(s)"`
|
||||
Created time.Time `xorm:"created"`
|
||||
}
|
||||
|
||||
func AddAccess(access *Access) error {
|
||||
_, err := orm.Insert(access)
|
||||
return err
|
||||
}
|
||||
|
||||
// if one user can read or write one repository
|
||||
func HasAccess(userName, repoName, mode string) (bool, error) {
|
||||
return orm.Get(&Access{0, strings.ToLower(userName), strings.ToLower(repoName), mode})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue