2022-09-05 15:55:08 +00:00
|
|
|
package controllers
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
2022-09-24 13:01:33 +00:00
|
|
|
"officeHours/templating"
|
2022-09-05 15:55:08 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func (b *BaseHandler) ConfirmRequestHandler(w http.ResponseWriter, req *http.Request) {
|
|
|
|
secret := req.FormValue("code")
|
|
|
|
request, err := b.requestRepo.FindBySecret(secret)
|
|
|
|
|
|
|
|
if err != nil {
|
2022-09-26 10:42:08 +00:00
|
|
|
w.WriteHeader(http.StatusNotFound)
|
2022-09-24 13:01:33 +00:00
|
|
|
templating.ServeTemplate(w, "requestNotFound", nil)
|
2022-09-13 05:28:13 +00:00
|
|
|
return
|
2022-09-05 15:55:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
err = b.requestRepo.Execute(request)
|
|
|
|
if err != nil {
|
2022-09-26 10:42:08 +00:00
|
|
|
w.WriteHeader(http.StatusInternalServerError)
|
2022-09-24 13:01:33 +00:00
|
|
|
templating.ServeTemplate(w, "executeFailure", err.Error())
|
2022-09-07 19:48:40 +00:00
|
|
|
return
|
2022-09-05 15:55:08 +00:00
|
|
|
}
|
2022-09-24 13:01:33 +00:00
|
|
|
templating.ServeTemplate(w, "executeSuccess", nil)
|
2022-09-07 19:48:40 +00:00
|
|
|
|
2022-09-05 15:55:08 +00:00
|
|
|
}
|