TokenizeIdentityField tokenizes a specific field in an identity. It extracts the identity ID and field name from the route parameters, tokenizes the field, and responds with a success message. Parameters: - c: The Gin context containing the request and response. Responses: - 400 Bad Request: If th
(c *gin.Context)
| 250 | // - 400 Bad Request: If the ID or field is missing, or there's an error tokenizing the field. |
| 251 | // - 200 OK: If the field is successfully tokenized. |
| 252 | func (a Api) TokenizeIdentityField(c *gin.Context) { |
| 253 | id, idExists := c.Params.Get("id") |
| 254 | field, fieldExists := c.Params.Get("field") |
| 255 | |
| 256 | if !idExists { |
| 257 | c.JSON(http.StatusBadRequest, gin.H{"error": "identity ID is required"}) |
| 258 | return |
| 259 | } |
| 260 | |
| 261 | if !fieldExists { |
| 262 | c.JSON(http.StatusBadRequest, gin.H{"error": "field name is required"}) |
| 263 | return |
| 264 | } |
| 265 | |
| 266 | err := a.ledgerforge.TokenizeIdentityField(id, field) |
| 267 | if err != nil { |
| 268 | c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) |
| 269 | return |
| 270 | } |
| 271 | |
| 272 | c.JSON(http.StatusOK, gin.H{"message": "Field tokenized successfully"}) |
| 273 | } |
| 274 | |
| 275 | // DetokenizeIdentityField detokenizes a specific field in an identity. |
| 276 | // It extracts the identity ID and field name from the route parameters, |