diff --git a/src/consent_api.go b/src/consent_api.go index 098025c..36c0626 100644 --- a/src/consent_api.go +++ b/src/consent_api.go @@ -62,9 +62,11 @@ func (e mainEnv) consentAccept(w http.ResponseWriter, r *http.Request, ps httpro status = value.(string) } } - if len(brief) == 0 { - //returnError(w, r, "internal error", 405, nil, event) - return + switch mode { + case "email": + address = normalizeEmail(address) + case "phone": + address = normalizePhone(address, e.conf.Sms.Default_country) } e.db.createConsentRecord(userTOKEN, mode, address, brief, message, status) } @@ -103,6 +105,12 @@ func (e mainEnv) consentCancel(w http.ResponseWriter, r *http.Request, ps httpro if e.enforceAuth(w, r, event) == false { return } + switch mode { + case "email": + address = normalizeEmail(address) + case "phone": + address = normalizePhone(address, e.conf.Sms.Default_country) + } e.db.cancelConsentRecord(userTOKEN, brief, mode, address) w.Header().Set("Content-Type", "application/json; charset=utf-8") w.WriteHeader(200)