aboutsummaryrefslogtreecommitdiff
path: root/modules/middleware/context.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/middleware/context.go')
-rw-r--r--modules/middleware/context.go17
1 files changed, 15 insertions, 2 deletions
diff --git a/modules/middleware/context.go b/modules/middleware/context.go
index 2995d578..9870b415 100644
--- a/modules/middleware/context.go
+++ b/modules/middleware/context.go
@@ -72,9 +72,14 @@ type RepoContext struct {
Mirror *models.Mirror
}
-// Return if the current user has write access for this repository
+// IsOwner returns true if current user is the owner of repository.
func (r RepoContext) IsOwner() bool {
- return r.AccessMode >= models.ACCESS_MODE_WRITE
+ return r.AccessMode >= models.ACCESS_MODE_OWNER
+}
+
+// IsAdmin returns true if current user has admin or higher access of repository.
+func (r RepoContext) IsAdmin() bool {
+ return r.AccessMode >= models.ACCESS_MODE_ADMIN
}
// Return if the current user has read access for this repository
@@ -197,6 +202,14 @@ func Contexter() macaron.Handler {
ctx.Data["PageStartTime"] = time.Now()
+ // Check auto-signin.
+ if sess.Get("uid") == nil {
+ if _, err := AutoSignIn(ctx); err != nil {
+ ctx.Handle(500, "AutoSignIn", err)
+ return
+ }
+ }
+
// Get user from session if logined.
ctx.User, ctx.IsBasicAuth = auth.SignedInUser(ctx.Req.Request, ctx.Session)