Ask for reason before executing the operation

This commit is contained in:
root
2020-12-05 15:46:54 +00:00
parent 0f09b134f3
commit 1806451389
2 changed files with 12 additions and 3 deletions

View File

@@ -284,6 +284,12 @@ func (e mainEnv) cancelUserRequest(w http.ResponseWriter, r *http.Request, ps ht
if enforceUUID(w, request, event) == false {
return
}
records, err := getJSONPostData(r)
if err != nil {
returnError(w, r, "failed to decode request body", 405, err, event)
return
}
reason := getStringValue(records, "reason");
requestInfo, err := e.db.getRequest(request)
if err != nil {
returnError(w, r, "internal error", 405, err, event)
@@ -315,8 +321,7 @@ func (e mainEnv) cancelUserRequest(w http.ResponseWriter, r *http.Request, ps ht
returnError(w, r, "not found", 405, err, event)
return
}
reason := ""
if authResult == "login" {
if len(reason) == 0 && authResult == "login" {
reason = "user operation"
}
e.db.updateRequestStatus(request, "canceled", reason)

View File

@@ -85,7 +85,11 @@
<label for="reason" class="col-sm-3 col-form-label">Reason</label>
<div class="col-sm-9"><textarea class="form-control" id="reason" rows="2"></textarea>
</div></div></form>`;
var btn = `<button type="submit" class="btn btn-primary" id="submitButton">Approve</button>`;
var bTitle = 'Approve';
if (action == "cancel") {
bTitle = 'Reject';
}
var btn = `<button type="submit" class="btn btn-primary" id="submitButton">`+bTitle+`</button>`;
var modal = showForm(title0, form, btn);
modal.find('#submitButton').click(function (event) {
modal.modal('hide');