From 8b14fabf78ad4a0abf718a59fc1fed410b2df4fa Mon Sep 17 00:00:00 2001 From: root Date: Thu, 1 Oct 2020 18:56:49 +0000 Subject: [PATCH] crate default consents on setup --- create-test-user.sh | 26 ++++++++------------------ src/bunker.go | 6 ++++++ ui/index.html | 4 ++-- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/create-test-user.sh b/create-test-user.sh index 7436bc8..870daa4 100755 --- a/create-test-user.sh +++ b/create-test-user.sh @@ -18,29 +18,19 @@ RESULT=`curl -s $DATABUNKER/v1/lbasis/send-sms -XPOST \ -d '{"module":"signup","fulldesc":"full","shortdesc":"short","requiredmsg":"required","usercontrol":false,"requiredflag":true}'` echo "Create legal basis entity: $RESULT" -RESULT=`curl -s $DATABUNKER/v1/lbasis/send-sms-on-login -XPOST \ - -H "X-Bunker-Token: $XTOKEN" -H "Content-Type: application/json" \ - -d '{"module":"signup","fulldesc":"full","shortdesc":"short","requiredmsg":"required","usercontrol":false,"requiredflag":true}'` -echo "Create legal basis entity 2: $RESULT" - -RESULT=`curl -s $DATABUNKER/v1/lbasis/send-email-on-login -XPOST \ - -H "X-Bunker-Token: $XTOKEN" -H "Content-Type: application/json" \ - -d '{"module":"signup","fulldesc":"full","shortdesc":"short","requiredmsg":"required","usercontrol":false,"requiredflag":true}'` -echo "Create legal basis entity 3: $RESULT" - RESULT=`curl -s $DATABUNKER/v1/pactivity/share-data-with-sms-provider/blah -XPOST \ -H "X-Bunker-Token: $XTOKEN"` echo "Tryingto link fake legal basis to processing activity: $RESULT" -RESULT=`curl -s $DATABUNKER/v1/pactivity/share-data-with-sms-provider/send-sms-on-login -XPOST \ +RESULT=`curl -s $DATABUNKER/v1/pactivity/share-data-with-sms-provider/core-send-sms-on-login -XPOST \ -H "X-Bunker-Token: $XTOKEN"` echo "Linking existing legal basis 2 to processing activity: $RESULT" -RESULT=`curl -s $DATABUNKER/v1/pactivity/share-data-with-sms-provider/send-sms-on-login -XPOST \ +RESULT=`curl -s $DATABUNKER/v1/pactivity/share-data-with-sms-provider/core-send-sms-on-login -XPOST \ -H "X-Bunker-Token: $XTOKEN"` echo "Linking again existing legal basis 2 to processing activity: $RESULT" -RESULT=`curl -s $DATABUNKER/v1/pactivity/share-data-with-sms-provider/send-email-on-login -XPOST \ +RESULT=`curl -s $DATABUNKER/v1/pactivity/share-data-with-sms-provider/core-send-email-on-login -XPOST \ -H "X-Bunker-Token: $XTOKEN"` echo "Linking existing legal basis 3 to processing activity: $RESULT" @@ -61,12 +51,12 @@ echo "Get a list of legal basis objects: $RESULT" RESULT=`curl -s $DATABUNKER/v1/lbasis/send-sms -XDELETE -H "X-Bunker-Token: $XTOKEN"` echo "Deleting legal basis object: $RESULT" -RESULT=`curl -s $DATABUNKER/v1/agreement/send-sms-on-login/email/test@paranoidguy.com -XPOST \ +RESULT=`curl -s $DATABUNKER/v1/agreement/core-send-sms-on-login/email/test@paranoidguy.com -XPOST \ -H "X-Bunker-Token: $XTOKEN" -H "Content-Type: application/json" \ -d '{"lawfulbasis":"contract"}'` echo "Giving consent for legal basis obj 2: $RESULT" -RESULT=`curl -s $DATABUNKER/v1/agreement/send-sms-on-login -XDELETE -H "X-Bunker-Token: $XTOKEN"` +RESULT=`curl -s $DATABUNKER/v1/agreement/core-send-sms-on-login -XDELETE -H "X-Bunker-Token: $XTOKEN"` echo "Revoking legal basis object 2: $RESULT" RESULT=`curl -s $DATABUNKER/v1/agreement/contract-approval/email/test@paranoidguy.com -XPOST \ @@ -74,7 +64,7 @@ RESULT=`curl -s $DATABUNKER/v1/agreement/contract-approval/email/test@paranoidgu -d '{"lawfulbasis":"contract"}'` echo "Giving consent for fake legal basis: $RESULT" -RESULT=`curl -s $DATABUNKER/v1/agreement/send-sms-on-login/email/test@paranoidguy.com -XDELETE -H "X-Bunker-Token: $XTOKEN"` +RESULT=`curl -s $DATABUNKER/v1/agreement/core-send-sms-on-login/email/test@paranoidguy.com -XDELETE -H "X-Bunker-Token: $XTOKEN"` echo "Withdraw legal basis 2 consent: $RESULT" echo "Creating user." @@ -132,11 +122,11 @@ RESULT=`curl -s $DATABUNKER/v1/agreement/send-sms/token/$TOKEN -XPOST \ -H "X-Bunker-Token: $XTOKEN" -d "expiration=30s"` echo "Enable consent send-sms for user by token: $RESULT" -RESULT=`curl -s $DATABUNKER/v1/agreement/send-sms-on-login/email/test@paranoidguy.com -XPOST \ +RESULT=`curl -s $DATABUNKER/v1/agreement/core-send-sms-on-login/email/test@paranoidguy.com -XPOST \ -H "X-Bunker-Token: $XTOKEN"` echo "Enable consent send-sms for user by email: $RESULT" -RESULT=`curl -s $DATABUNKER/v1/agreement/send-sms-on-login/phone/4444 -XDELETE \ +RESULT=`curl -s $DATABUNKER/v1/agreement/core-send-sms-on-login/phone/4444 -XDELETE \ -H "X-Bunker-Token: $XTOKEN"` echo "Withdraw consent send-sms for user by phone: $RESULT" diff --git a/src/bunker.go b/src/bunker.go index 6316c81..e588be3 100644 --- a/src/bunker.go +++ b/src/bunker.go @@ -418,6 +418,12 @@ func setupDB(dbPtr *string, masterKeyPtr *string, customRootToken string) (*dbco //log.Panic("error %s", err.Error()) fmt.Printf("error %s", err.Error()) } + db.createLegalBasis("core-send-email-on-login", "", "login", "Send email on login", + "Confirm to allow sending access code using 3rd party email gateway", "consent", + "This consent is required to give you the service.", "active", true, true); + db.createLegalBasis("core-send-sms-on-login", "", "login", "Send SMS on login", + "Confirm to allow sending access code using 3rd party SMS gateway", "consent", + "This consent is required to give you the service.", "active", true, true); fmt.Printf("\nAPI Root token: %s\n\n", rootToken) return db, rootToken, err } diff --git a/ui/index.html b/ui/index.html index c6d2237..2934250 100644 --- a/ui/index.html +++ b/ui/index.html @@ -227,7 +227,7 @@ if (conf["custom_css_link"]) { } else if (kkk == "Email" && key.indexOf('@') > 0) { window.localStorage.setItem('login', key); var xhr0 = new XMLHttpRequest(); - xhr0.open('POST', "/v1/agreement/send-email-on-login/email/" + encodeURI(key) + ""); + xhr0.open('POST', "/v1/agreement/core-send-email-on-login/email/" + encodeURI(key) + ""); xhr0.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); xhr0.onload = function () { if (xhr0.status === 200) { @@ -254,7 +254,7 @@ if (conf["custom_css_link"]) { } else if (kkk == "Phone") { window.localStorage.setItem('login', key); var xhr0 = new XMLHttpRequest(); - xhr0.open('POST', "/v1/agreement/send-sms-on-login/phone/" + encodeURI(key) + ""); + xhr0.open('POST', "/v1/agreement/core-send-sms-on-login/phone/" + encodeURI(key) + ""); xhr0.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); xhr0.onload = function () { if (xhr0.status === 200) {