add support for user lookup by different indeces

This commit is contained in:
yuli
2024-08-15 20:11:59 +03:00
parent 0c797e5d2b
commit 37febca2e1
2 changed files with 6 additions and 4 deletions

View File

@@ -210,7 +210,7 @@ func (e mainEnv) setupRouter() *httprouter.Router {
router.POST("/v1/exp/start/:mode/:identity", e.expStart)
router.DELETE("/v1/exp/cancel/:mode/:identity", e.expCancel)
router.POST("/v1/sharedrecord/token/:token", e.newSharedRecord)
router.POST("/v1/sharedrecord/:mode/:identity", e.newSharedRecord)
router.GET("/v1/get/:record", e.getRecord)
router.GET("/v1/request/:request", e.getUserRequest)

View File

@@ -13,11 +13,13 @@ import (
)
func (e mainEnv) newSharedRecord(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
userTOKEN := ps.ByName("token")
event := audit("create shareable record by user token", userTOKEN, "token", userTOKEN)
identity := ps.ByName("identity")
mode := ps.ByName("mode")
event := audit("create shareable record by "+mode, identity, "token", identity)
defer func() { event.submit(e.db, e.conf) }()
if enforceUUID(w, userTOKEN, event) == false {
userTOKEN := e.loadUserToken(w, r, mode, identity, event)
if userTOKEN == "" {
return
}
if e.enforceAuth(w, r, event) == "" {