24 lines
590 B
Go
24 lines
590 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, err := template.ParseFiles("templates/executeFailure.html")
|
|
tmpl.Execute(w, err)
|
|
}
|
|
}
|