Verify exchanges a confirmation or recovery token to a refresh token
(w http.ResponseWriter, r *http.Request)
| 93 | |
| 94 | // Verify exchanges a confirmation or recovery token to a refresh token |
| 95 | func (a *API) Verify(w http.ResponseWriter, r *http.Request) error { |
| 96 | params := &VerifyParams{} |
| 97 | switch r.Method { |
| 98 | case http.MethodGet: |
| 99 | params.Token = r.FormValue("token") |
| 100 | params.Type = r.FormValue("type") |
| 101 | params.RedirectTo = utilities.GetReferrer(r, a.config) |
| 102 | if err := params.Validate(r, a); err != nil { |
| 103 | return err |
| 104 | } |
| 105 | return a.verifyGet(w, r, params) |
| 106 | case http.MethodPost: |
| 107 | if err := retrieveRequestParams(r, params); err != nil { |
| 108 | return err |
| 109 | } |
| 110 | if err := params.Validate(r, a); err != nil { |
| 111 | return err |
| 112 | } |
| 113 | return a.verifyPost(w, r, params) |
| 114 | default: |
| 115 | // this should have been handled by Chi |
| 116 | panic("Only GET and POST methods allowed") |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | func (a *API) verifyGet(w http.ResponseWriter, r *http.Request, params *VerifyParams) error { |
| 121 | ctx := r.Context() |
nothing calls this directly
no test coverage detected