diff options
author | Peter Smit <peter@smitmail.eu> | 2015-02-12 14:25:07 +0200 |
---|---|---|
committer | Peter Smit <peter@smitmail.eu> | 2015-02-12 14:25:07 +0200 |
commit | 6c1ee384f1a45ed97f39b085209bcb79cafd9145 (patch) | |
tree | 0798c98ff2fa93324edae6cfcb539cf51fc4b7fd /models | |
parent | 0a4cda0dd4d7c906668d9d2e283fbe9ebe2e1608 (diff) | |
parent | 0d158e569b0c19614b5e946849e8b7a8e4a75015 (diff) | |
download | gitea-6c1ee384f1a45ed97f39b085209bcb79cafd9145.tar.gz gitea-6c1ee384f1a45ed97f39b085209bcb79cafd9145.zip |
Merge remote-tracking branch 'mine/access_refactor' into access_refactor
Conflicts:
cmd/serve.go
models/access.go
models/migrations/migrations.go
models/org.go
models/repo.go
models/user.go
modules/middleware/org.go
modules/middleware/repo.go
routers/api/v1/repo.go
routers/org/teams.go
routers/repo/http.go
routers/user/home.go
Diffstat (limited to 'models')
-rw-r--r-- | models/access.go | 24 | ||||
-rw-r--r-- | models/org.go | 2 | ||||
-rw-r--r-- | models/user.go | 1 |
3 files changed, 14 insertions, 13 deletions
diff --git a/models/access.go b/models/access.go index d85f24cd06..174aca987f 100644 --- a/models/access.go +++ b/models/access.go @@ -7,15 +7,15 @@ package models type AccessMode int const ( - NoAccess AccessMode = iota - ReadAccess - WriteAccess - AdminAccess - OwnerAccess + ACCESS_MODE_NONE AccessMode = iota + ACCESS_MODE_READ + ACCESS_MODE_WRITE + ACCESS_MODE_ADMIN + ACCESS_MODE_OWNER ) func maxAccessMode(modes ...AccessMode) AccessMode { - max := NoAccess + max := ACCESS_MODE_NONE for _, mode := range modes { if mode > max { max = mode @@ -43,14 +43,14 @@ func HasAccess(u *User, r *Repository, testMode AccessMode) (bool, error) { // Return the Access a user has to a repository. Will return NoneAccess if the // user does not have access. User can be nil! func AccessLevel(u *User, r *Repository) (AccessMode, error) { - mode := NoAccess + mode := ACCESS_MODE_NONE if !r.IsPrivate { - mode = ReadAccess + mode = ACCESS_MODE_READ } if u != nil { if u.Id == r.OwnerId { - return OwnerAccess, nil + return ACCESS_MODE_OWNER, nil } a := &Access{UserID: u.Id, RepoID: r.Id} @@ -98,7 +98,7 @@ func (r *Repository) RecalcAccessSess() error { return err } for _, c := range collaborators { - accessMap[c.Id] = WriteAccess + accessMap[c.Id] = ACCESS_MODE_WRITE } if err := r.GetOwner(); err != nil { @@ -123,9 +123,9 @@ func (r *Repository) RecalcAccessSess() error { } } - minMode := ReadAccess + minMode := ACCESS_MODE_READ if !r.IsPrivate { - minMode = WriteAccess + minMode = ACCESS_MODE_WRITE } newAccesses := make([]Access, 0, len(accessMap)) diff --git a/models/org.go b/models/org.go index 775caa8639..d667fb26dc 100644 --- a/models/org.go +++ b/models/org.go @@ -134,7 +134,7 @@ func CreateOrganization(org, owner *User) (*User, error) { OrgId: org.Id, LowerName: strings.ToLower(OWNER_TEAM), Name: OWNER_TEAM, - Authorize: OwnerAccess, + Authorize: ACCESS_MODE_OWNER, NumMembers: 1, } if _, err = sess.Insert(t); err != nil { diff --git a/models/user.go b/models/user.go index 9a6f93a474..7e3dc260e5 100644 --- a/models/user.go +++ b/models/user.go @@ -395,6 +395,7 @@ func ChangeUserName(u *User, newUserName string) (err error) { if !IsLegalName(newUserName) { return ErrUserNameIllegal } + return os.Rename(UserPath(u.LowerName), UserPath(newUserName)) } |