From 83e03c1257040c3b46f5f9b31daabc0a819f47ed Mon Sep 17 00:00:00 2001 From: Vsevolod Strukchinsky Date: Fri, 20 Feb 2015 12:05:39 +0500 Subject: [PATCH] Do not request Read permission for public repo Closes #882 --- server/handler/ws.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/server/handler/ws.go b/server/handler/ws.go index f27649c9..150d9ddb 100644 --- a/server/handler/ws.go +++ b/server/handler/ws.go @@ -1,6 +1,7 @@ package handler import ( + "database/sql" "log" "net/http" "strconv" @@ -65,14 +66,15 @@ func WsUser(c web.C, w http.ResponseWriter, r *http.Request) { break } - // user must have read access to the repository + role, permerr := datastore.GetPerm(ctx, user, work.Repo) + if permerr != nil && permerr != sql.ErrNoRows { + // for debugging + log.Printf("WS: Error getting permissions for repository %s. Error: %s\n", work.Repo.Name, permerr) + } + + // user must have read access to private the repository // in order to pass this message along - if role, err := datastore.GetPerm(ctx, user, work.Repo); err != nil || role.Read == false { - if err != nil { - log.Printf("WS: Error getting permissions for repository %s. Error: %s\n", work.Repo.Name, err) - } else { - log.Printf("WS: No read access for repository %s\n", work.Repo.Name) - } + if work.Repo.Private == true && role.Read == false { break }