renderConfirmPage validates the token, loads the pending message, and renders an HTML page with a POST form targeting the same endpoint. The body preview lives on this page — not in the notification email — so sensitive content stays behind a token-gated server render rather than passing through the
(w http.ResponseWriter, r *http.Request, endpointAction string)
| 41 | // so sensitive content stays behind a token-gated server render rather |
| 42 | // than passing through the reviewer's mail infrastructure. |
| 43 | func (a *API) renderConfirmPage(w http.ResponseWriter, r *http.Request, endpointAction string) { |
| 44 | if a.approvalSigner == nil { |
| 45 | http.NotFound(w, r) |
| 46 | return |
| 47 | } |
| 48 | token := r.URL.Query().Get("t") |
| 49 | claims, status, errMsg := a.verifyMagicToken(token, endpointAction) |
| 50 | if errMsg != "" { |
| 51 | writeMagicMessage(w, status, pageTitleForAction(endpointAction, "Invalid link"), errMsg) |
| 52 | return |
| 53 | } |
| 54 | |
| 55 | // Load message via ownership-scoped read so the confirmation page |
| 56 | // surfaces the real detail (recipients, subject, body preview). |
| 57 | userID, _, err := a.store.ResolveOutboundOwner(r.Context(), claims.MessageID) |
| 58 | if err != nil { |
| 59 | writeMagicMessage(w, http.StatusNotFound, "Message not found", |
| 60 | "This message no longer exists.") |
| 61 | return |
| 62 | } |
| 63 | msg, err := a.store.GetOutboundMessageForUser(r.Context(), claims.MessageID, userID) |
| 64 | if err != nil { |
| 65 | writeMagicMessage(w, http.StatusNotFound, "Message not found", |
| 66 | "This message no longer exists.") |
| 67 | return |
| 68 | } |
| 69 | if msg.Status != identity.MessageStatusPendingReview { |
| 70 | writeMagicMessage(w, http.StatusConflict, "Already resolved", |
| 71 | "This message has already been approved, rejected, or expired.") |
| 72 | return |
| 73 | } |
| 74 | |
| 75 | writeConfirmPage(w, http.StatusOK, endpointAction, token, msg) |
| 76 | } |
| 77 | |
| 78 | // --- POST executors --- |
| 79 |
no test coverage detected