func AuthPage(w http.ResponseWriter, r *http.Request) { r.ParseForm() dec := schema.NewDecoder() authResp := struct { AuthResponse Err string }{} err := dec.Decode(&authResp, r.Form) if err != nil { authResp.Err = err.Error() } authTemplate.Execute(w, authResp) }
func doInstall(w http.ResponseWriter, r *http.Request) { r.ParseForm() dec := schema.NewDecoder() var authResp AuthResponse err := dec.Decode(&authResp, r.Form) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) return } var session *sessions.Session if err := pc.GetSession(cookieJar, r, &session); err != nil { http.Error(w, err.Message, err.HttpStatus) return } userToken, ok := session.Values["INSTALL_USER_TOKEN"].(string) if !ok { http.Error(w, "Could not find user token in session", http.StatusBadRequest) return } authResp.UserToken = userToken session.Values["INSTALL_USER_TOKEN"] = nil session.Values["INSTALL_AUTH_RESPONSE"] = &authResp if err := cookieJar.Save(r, w, session); err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } http.Redirect(w, r, redirUrlBase.String()+"#/install", http.StatusFound) }