| Index: appengine/chromium_build_stats/default/auth.go
|
| diff --git a/appengine/chromium_build_stats/default/auth.go b/appengine/chromium_build_stats/default/auth.go
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..d1e71c5fdf461df48c908fe9f03f1b45da787a8b
|
| --- /dev/null
|
| +++ b/appengine/chromium_build_stats/default/auth.go
|
| @@ -0,0 +1,38 @@
|
| +package chromiumbuildstats
|
| +
|
| +import (
|
| + "html/template"
|
| + "net/http"
|
| +
|
| + "appengine"
|
| + "appengine/user"
|
| +)
|
| +
|
| +func authPage(w http.ResponseWriter, req *http.Request, status int, tmpl *template.Template, u *user.User, reqpath string) {
|
| + ctx := appengine.NewContext(req)
|
| + login, err := user.LoginURL(ctx, reqpath)
|
| + if err != nil {
|
| + http.Error(w, err.Error(), http.StatusInternalServerError)
|
| + return
|
| + }
|
| + logout, err := user.LogoutURL(ctx, reqpath)
|
| + if err != nil {
|
| + http.Error(w, err.Error(), http.StatusInternalServerError)
|
| + return
|
| + }
|
| + w.Header().Set("Content-Type", "text/html")
|
| + w.WriteHeader(status)
|
| + data := struct {
|
| + User *user.User
|
| + Login string
|
| + Logout string
|
| + }{
|
| + User: u,
|
| + Login: login,
|
| + Logout: logout,
|
| + }
|
| + err = tmpl.Execute(w, data)
|
| + if err != nil {
|
| + ctx.Errorf("tmpl: %v", err)
|
| + }
|
| +}
|
|
|