mirror of
https://github.com/optim-enterprises-bv/databunker.git
synced 2026-01-09 17:11:28 +00:00
new structure
This commit is contained in:
@@ -253,7 +253,7 @@ func (e mainEnv) approveUserRequest(w http.ResponseWriter, r *http.Request, ps h
|
||||
lastmodifiedby := "admin"
|
||||
e.db.withdrawConsentRecord(userTOKEN, brief, mode, userTOKEN, lastmodifiedby)
|
||||
}
|
||||
e.db.updateRequestStatus(request, "approve")
|
||||
e.db.updateRequestStatus(request, "approve", "")
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
w.WriteHeader(200)
|
||||
fmt.Fprintf(w, `{"status":"ok","result":"done"}`)
|
||||
@@ -298,7 +298,11 @@ func (e mainEnv) cancelUserRequest(w http.ResponseWriter, r *http.Request, ps ht
|
||||
returnError(w, r, "not found", 405, err, event)
|
||||
return
|
||||
}
|
||||
e.db.updateRequestStatus(request, "canceled")
|
||||
reason := ""
|
||||
if authResult == "login" {
|
||||
reason = "user operation"
|
||||
}
|
||||
e.db.updateRequestStatus(request, "canceled", reason)
|
||||
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
w.WriteHeader(200)
|
||||
|
||||
@@ -20,6 +20,7 @@ type requestEvent struct {
|
||||
Status string `json:"status"`
|
||||
Change string `json:"change,omitempty"`
|
||||
Rtoken string `json:"rtoken"`
|
||||
Reason string `json:"reason"`
|
||||
}
|
||||
|
||||
func (dbobj dbcon) saveUserRequest(action string, token string, app string, brief string, change []byte) (string, error) {
|
||||
@@ -131,9 +132,12 @@ func (dbobj dbcon) getRequest(rtoken string) (bson.M, error) {
|
||||
return record, nil
|
||||
}
|
||||
|
||||
func (dbobj dbcon) updateRequestStatus(rtoken string, status string) {
|
||||
func (dbobj dbcon) updateRequestStatus(rtoken string, status string, reason string) {
|
||||
bdoc := bson.M{}
|
||||
bdoc["status"] = status
|
||||
if len(reason) > 0 {
|
||||
bdoc["reason"] = reason
|
||||
}
|
||||
//fmt.Printf("op json: %s\n", update)
|
||||
dbobj.store.UpdateRecord(storage.TblName.Requests, "rtoken", rtoken, &bdoc)
|
||||
}
|
||||
|
||||
@@ -941,6 +941,7 @@ func initRequests(db *sql.DB) error {
|
||||
action STRING,
|
||||
status STRING,
|
||||
change STRING,
|
||||
reason STRING,
|
||||
creationtime int,
|
||||
` + "`when` int);",
|
||||
`CREATE INDEX requests_rtoken ON requests (rtoken);`,
|
||||
|
||||
Reference in New Issue
Block a user