(w http.ResponseWriter, r *http.Request)
| 98 | } |
| 99 | |
| 100 | func (a *API) handleRejectMagicLinkPost(w http.ResponseWriter, r *http.Request) { |
| 101 | if a.approvalSigner == nil { |
| 102 | http.NotFound(w, r) |
| 103 | return |
| 104 | } |
| 105 | token := extractFormToken(r) |
| 106 | claims, status, errMsg := a.verifyMagicToken(token, approvaltoken.ActionReject) |
| 107 | if errMsg != "" { |
| 108 | writeMagicMessage(w, status, "Invalid confirmation", errMsg) |
| 109 | return |
| 110 | } |
| 111 | userID, _, err := a.store.ResolveOutboundOwner(r.Context(), claims.MessageID) |
| 112 | if err != nil { |
| 113 | writeMagicMessage(w, http.StatusNotFound, "Message not found", |
| 114 | "This message no longer exists.") |
| 115 | return |
| 116 | } |
| 117 | reason := strings.TrimSpace(r.FormValue("reason")) |
| 118 | if reason == "" { |
| 119 | reason = "magic-link rejection" |
| 120 | } |
| 121 | a.magicReject(w, r, claims.MessageID, userID, reason) |
| 122 | } |
| 123 | |
| 124 | // extractFormToken pulls the token from standard form encoding. Request |
| 125 | // body is expected to be application/x-www-form-urlencoded since the |
nothing calls this directly
no test coverage detected