2022-09-05 15:55:08 +00:00
|
|
|
package controllers
|
|
|
|
|
|
|
|
import (
|
|
|
|
"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)
|
2022-09-13 05:28:13 +00:00
|
|
|
Templates.ExecuteTemplate(w, "requestNotFound.html", struct{}{})
|
|
|
|
return
|
2022-09-05 15:55:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
err = b.requestRepo.Execute(request)
|
|
|
|
if err != nil {
|
|
|
|
w.WriteHeader(http.StatusInternalServerError)
|
2022-09-13 05:28:13 +00:00
|
|
|
Templates.ExecuteTemplate(w, "executeFailure.html", err.Error())
|
2022-09-07 19:48:40 +00:00
|
|
|
return
|
2022-09-05 15:55:08 +00:00
|
|
|
}
|
2022-09-13 05:28:13 +00:00
|
|
|
Templates.ExecuteTemplate(w, "executeSuccess.html", struct{}{})
|
2022-09-07 19:48:40 +00:00
|
|
|
|
2022-09-05 15:55:08 +00:00
|
|
|
}
|