ResponseWithChallenge mixes together a JSON body (e.g an error with errcode/message) with the standard challenge response.
(sessionID string, response interface{})
| 177 | // ResponseWithChallenge mixes together a JSON body (e.g an error with errcode/message) with the |
| 178 | // standard challenge response. |
| 179 | func (u *UserInteractive) ResponseWithChallenge(sessionID string, response interface{}) *util.JSONResponse { |
| 180 | mixedObjects := make(map[string]interface{}) |
| 181 | b, err := json.Marshal(response) |
| 182 | if err != nil { |
| 183 | ise := jsonerror.InternalServerError() |
| 184 | return &ise |
| 185 | } |
| 186 | _ = json.Unmarshal(b, &mixedObjects) |
| 187 | challenge := u.Challenge(sessionID) |
| 188 | b, err = json.Marshal(challenge.JSON) |
| 189 | if err != nil { |
| 190 | ise := jsonerror.InternalServerError() |
| 191 | return &ise |
| 192 | } |
| 193 | _ = json.Unmarshal(b, &mixedObjects) |
| 194 | |
| 195 | return &util.JSONResponse{ |
| 196 | Code: 401, |
| 197 | JSON: mixedObjects, |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | // Verify returns an error/challenge response to send to the client, or nil if the user is authenticated. |
| 202 | // `bodyBytes` is the HTTP request body which must contain an `auth` key. |