save identity of last user doing operation

This commit is contained in:
stremovsky
2019-12-14 18:13:32 +02:00
parent 40cfa5480c
commit 03b9936a52
2 changed files with 4 additions and 2 deletions

View File

@@ -103,7 +103,7 @@ func (e mainEnv) consentCancel(w http.ResponseWriter, r *http.Request, ps httpro
if e.enforceAuth(w, r, event) == false {
return
}
e.db.cancelConsentRecord(userTOKEN, brief)
e.db.cancelConsentRecord(userTOKEN, brief, mode, address)
w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(200)
w.Write([]byte(`{"status":"ok"}`))

View File

@@ -58,7 +58,7 @@ func (dbobj dbcon) createConsentRecord(userTOKEN string, mode string, usercode s
}
}
func (dbobj dbcon) cancelConsentRecord(userTOKEN string, brief string) error {
func (dbobj dbcon) cancelConsentRecord(userTOKEN string, brief string, mode string, usercode string) error {
// brief can not be too long, may be hash it ?
if len(brief) > 64 {
return errors.New("Brief value is too long")
@@ -68,6 +68,8 @@ func (dbobj dbcon) cancelConsentRecord(userTOKEN string, brief string) error {
// update date, status
bdoc := bson.M{}
bdoc["when"] = now
bdoc["mode"] = mode
bdoc["who"] = usercode
bdoc["status"] = "cancel"
dbobj.updateRecord2(TblName.Consent, "token", userTOKEN, "brief", brief, &bdoc, nil)
return nil