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

Side by Side Diff: appengine/chromium_build_stats/default/auth.go

Issue 2125513002: chromium_build_stats: redirect login url if not logged in. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Created 4 years, 5 months 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 unified diff | Download patch
OLDNEW
(Empty)
1 package chromiumbuildstats
2
3 import (
4 "html/template"
5 "net/http"
6
7 "appengine"
8 "appengine/user"
9 )
10
11 func authPage(w http.ResponseWriter, req *http.Request, status int, tmpl *templa te.Template, u *user.User, reqpath string) {
12 ctx := appengine.NewContext(req)
13 login, err := user.LoginURL(ctx, reqpath)
14 if err != nil {
15 http.Error(w, err.Error(), http.StatusInternalServerError)
16 return
17 }
18 logout, err := user.LogoutURL(ctx, reqpath)
19 if err != nil {
20 http.Error(w, err.Error(), http.StatusInternalServerError)
21 return
22 }
23 w.Header().Set("Content-Type", "text/html")
24 w.WriteHeader(status)
25 data := struct {
26 User *user.User
27 Login string
28 Logout string
29 }{
30 User: u,
31 Login: login,
32 Logout: logout,
33 }
34 err = tmpl.Execute(w, data)
35 if err != nil {
36 ctx.Errorf("tmpl: %v", err)
37 }
38 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698