use mode instead of type

This commit is contained in:
stremovsky
2019-12-12 20:57:53 +02:00
parent d8ab96ae45
commit c8295ca70e
3 changed files with 8 additions and 5 deletions

5
API.md
View File

@@ -275,7 +275,10 @@ Fetch by user token:
curl --header "X-Bunker-Token: $XTOKEN" -XGET \
https://localhost:3000/v1/consent/email/test@paranoidguy.com
{"status":"ok","total":2,"rows":[
{"brief":"send-email-mailgun-on-login","message":"send-email-mailgun-on-login","status":"accept","token":"254d2abf-e927-bdcf-9cb2-f43c3cb7a8fa","type":"email","when":1576154130,"who":"test@paranoidguy.com"},{"brief":"send-sms-twilio-on-login","message":"send-sms-twilio-on-login","status":"accept","token":"254d2abf-e927-bdcf-9cb2-f43c3cb7a8fa","type":"phone","when":1576174683,"who":"4444"}]}
{"brief":"send-email-mailgun-on-login","message":"send-email-mailgun-on-login","status":"accept",
"token":"254d2abf-e927-bdcf-9cb2-f43c3cb7a8fa","mode":"email","when":1576154130,"who":"test@paranoidguy.com"},
{"brief":"send-sms-twilio-on-login","message":"send-sms-twilio-on-login","status":"accept",
"token":"254d2abf-e927-bdcf-9cb2-f43c3cb7a8fa","mode":"phone","when":1576174683,"who":"4444"}]}
```
### List granted

View File

@@ -13,14 +13,14 @@ import (
type consentEvent struct {
When int32 `json:"when,omitempty" structs:"when"`
Who string `json:"who,omitempty" structs:"who"`
Type string `json:"type,omitempty" structs:"type"`
Mode string `json:"mode,omitempty" structs:"mode"`
Token string `json:"token,omitempty" structs:"token"`
Brief string `json:"brief,omitempty" structs:"brief"`
Message string `json:"message,omitempty" structs:"message"`
Status string `json:"status,omitempty" structs:"status"`
}
func (dbobj dbcon) createConsentRecord(userTOKEN string, usertype string, usercode string, brief string, message string, status string) {
func (dbobj dbcon) createConsentRecord(userTOKEN string, mode string, usercode string, brief string, message string, status string) {
now := int32(time.Now().Unix())
// brief can not be too long, may be hash it ?
if len(brief) > 64 {
@@ -47,7 +47,7 @@ func (dbobj dbcon) createConsentRecord(userTOKEN string, usertype string, userco
When: now,
Who: usercode,
Token: userTOKEN,
Type: usertype,
Mode: mode,
Brief: brief,
Message: message,
Status: status,

View File

@@ -150,7 +150,7 @@
}
var start = '<div class="d-flex flex-row bd-highlight mb-4">';
var d = '<div class="p-2 bd-highlight">When: ' + dateFormat(row.when) + '</div>'
var identity = '<div class="p-2 flex-fill bd-highlight">Identity: ' + row.who + ' (' + row.type + ')<br/>' + msg + '</div>'
var identity = '<div class="p-2 flex-fill bd-highlight">Identity: ' + row.who + ' (' + row.mode + ')<br/>' + msg + '</div>'
var cancel = "<a href=\"javascript:cancelThis('" + row.brief + "');\">cancel</a>";
var accept = "<a href=\"javascript:acceptThis('" + row.brief + "');\">accept</a>";
var op = cancel;