func UNUSEDhandleHome(w http.ResponseWriter, r *http.Request) { u := CurrentUser(r) var d time.Weekday if u != nil { d = weekdayForUser(r, u) } saveCurrentUser(r, w, u) var xf, xd string if u != nil { xf = xsrftoken.Generate(xsrfKey, u.ID, updateURL) xd = xsrftoken.Generate(xsrfKey, u.ID, deleteAccountURL) } homeTemplate := getHomeTpl(w, r) homeTemplate.Execute(w, map[string]interface{}{ "CookieDump": template.HTML(htmlfrag.CookieDump(r)), "WidgetURL": widgetSigninAuthorizedRedirectURL, "SignOutURL": signOutURL, "User": u, "WeekdayIndex": d, "Weekdays": weekdays, "UpdateWeekdayURL": updateURL, "UpdateWeekdayXSRFToken": xf, "DeleteAccountURL": deleteAccountURL, "DeleteAccountXSRFToken": xd, }) }
// Show status and show login/logut url func login(w http.ResponseWriter, r *http.Request) { r.Header.Set("X-Custom-Header-Counter", "nocounter") w.Header().Set("Content-type", "text/html; charset=utf-8") w.WriteHeader(http.StatusFound) c := appengine.NewContext(r) u, uType := UserFromReq(r) if u == nil { fmt.Fprintf(w, "%v<br>\n", uType) url, err := user.LoginURL(c, r.URL.String()) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } // forward to login // w.Header().Set("Location", url) fmt.Fprintf(w, "<a href='%v'>login</a><br>", url) } else { // this gets never executed on dev server fmt.Fprintf(w, "Hello, %v, %v, %v, %v!<br>\n", u, u.ID, u.Email, u.FederatedIdentity) fmt.Fprintf(w, "Login type <pre>%v</pre><br>\n", uType) url2, err := user.LogoutURL(c, r.URL.String()) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) } fmt.Fprintf(w, "<a href='%v'>logout</a><br>", url2) urlLogoutDocumented := "/_ah/login?action=logout" fmt.Fprintf(w, "<a href='%v'>%v</a><br>", urlLogoutDocumented, urlLogoutDocumented) } fmt.Fprintf(w, htmlfrag.CookieDump(r)) }