31 lines
770 B
Go
31 lines
770 B
Go
package controllers
|
|
|
|
import (
|
|
"html/template"
|
|
"net/http"
|
|
)
|
|
|
|
func (b *BaseHandler) ConfirmRequestHandler(w http.ResponseWriter, req *http.Request) {
|
|
secret := req.FormValue("code")
|
|
request, err := b.requestRepo.FindBySecret(secret)
|
|
|
|
if err != nil {
|
|
w.WriteHeader(http.StatusNotFound)
|
|
tmpl, _ := template.ParseFiles("templates/requestNotFound.html")
|
|
tmpl.Execute(w, struct{}{})
|
|
}
|
|
|
|
err = b.requestRepo.Execute(request)
|
|
if err != nil {
|
|
w.WriteHeader(http.StatusInternalServerError)
|
|
tmpl, _ := template.ParseFiles("templates/executeFailure.html")
|
|
tmpl.Execute(w, err.Error())
|
|
return
|
|
}
|
|
tmpl, err := template.ParseFiles("templates/executeSuccess.html")
|
|
if err != nil {
|
|
w.WriteHeader(http.StatusInternalServerError)
|
|
}
|
|
tmpl.Execute(w, struct{}{})
|
|
|
|
}
|