Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Unified Diff: milo/appengine/buildbot/build.go

Issue 2525493002: Milo: Add themed page for errors (Closed)
Patch Set: y Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | milo/appengine/buildbot/builder.go » ('j') | milo/appengine/buildbot/master.go » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: milo/appengine/buildbot/build.go
diff --git a/milo/appengine/buildbot/build.go b/milo/appengine/buildbot/build.go
index da6149f1ba18dbb590abe2867e611399511bdffb..f021ea0727fed9c0bfffcb3bc156ff2e70b431b8 100644
--- a/milo/appengine/buildbot/build.go
+++ b/milo/appengine/buildbot/build.go
@@ -20,6 +20,8 @@ import (
"github.com/luci/luci-go/milo/api/resp"
"github.com/luci/luci-go/milo/appengine/settings"
"github.com/luci/luci-go/milo/common/miloerror"
+ "github.com/luci/luci-go/server/auth"
+ "github.com/luci/luci-go/server/auth/identity"
"golang.org/x/net/context"
)
@@ -29,17 +31,30 @@ var errBuildNotFound = miloerror.Error{
}
// getBuild fetches a buildbot build from the datastore and checks ACLs.
+// The return code matches the master responses, that is:
+// User not logged in, master found, master public: 200
+// User not logged in, master not found: 401
+// User not logged in, master internal: 401
+// User logged in, master found, master internal: 200
+// User logged in, master not found: 404
+// User logged in, master found, master internal: 404
+// Other error: 500
func getBuild(c context.Context, master, builder string, buildNum int) (*buildbotBuild, error) {
result := &buildbotBuild{
Master: master,
Buildername: builder,
Number: buildNum,
}
+ cu := auth.CurrentUser(c)
err := ds.Get(c, result)
switch {
case err == ds.ErrNoSuchEntity:
- return nil, errBuildNotFound
+ if cu.Identity == identity.AnonymousIdentity {
+ return nil, errNotAuth
+ } else {
+ return nil, errBuildNotFound
+ }
case err != nil:
return nil, err
}
@@ -49,7 +64,11 @@ func getBuild(c context.Context, master, builder string, buildNum int) (*buildbo
return nil, err
}
if !allowed {
- return nil, errBuildNotFound
+ if cu.Identity == identity.AnonymousIdentity {
+ return nil, errNotAuth
+ } else {
+ return nil, errBuildNotFound
+ }
}
}
« no previous file with comments | « no previous file | milo/appengine/buildbot/builder.go » ('j') | milo/appengine/buildbot/master.go » ('J')

Powered by Google App Engine
This is Rietveld 408576698