client,mgr: pass on consent to terms to project

Let the project know that the user consented to the project's terms of
use when a new account is created for the user. The project can record
the consent for GDPR compliance.
This commit is contained in:
Juha Sointusalo 2018-10-25 23:55:26 +03:00
parent 5463a4d718
commit c5e4eca3af
9 changed files with 33 additions and 5 deletions

View File

@ -46,6 +46,7 @@ void ACCOUNT_IN::parse(XML_PARSER& xp) {
server_cookie = "";
ldap_auth = false;
server_assigned_cookie = false;
consented_to_terms = false;
while (!xp.get_tag()) {
if (xp.parse_string("url", url)) continue;
@ -56,6 +57,7 @@ void ACCOUNT_IN::parse(XML_PARSER& xp) {
if (xp.parse_string("server_cookie", server_cookie)) continue;
if (xp.parse_bool("ldap_auth", ldap_auth)) continue;
if (xp.parse_bool("server_assigned_cookie", server_assigned_cookie)) continue;
if (xp.parse_bool("consented_to_terms", consented_to_terms)) continue;
}
canonicalize_master_url(url);
}
@ -152,7 +154,7 @@ void LOOKUP_ACCOUNT_OP::handle_reply(int http_op_retval) {
}
}
int CREATE_ACCOUNT_OP::do_rpc(ACCOUNT_IN& ai) {
int CREATE_ACCOUNT_OP::do_rpc(ACCOUNT_IN& ai, string rpc_client_name) {
int retval;
string url;
string parameter;
@ -181,6 +183,13 @@ int CREATE_ACCOUNT_OP::do_rpc(ACCOUNT_IN& ai) {
escape_url(parameter);
url += parameter;
}
if (ai.consented_to_terms) {
parameter = rpc_client_name;
escape_url(parameter);
url += "&consent_flag=1&source=" + parameter;
}
retval = gui_http->do_rpc(
this, url.c_str(), CREATE_ACCOUNT_FILENAME, false
);

View File

@ -33,6 +33,7 @@ struct ACCOUNT_IN {
std::string server_cookie;
bool ldap_auth;
bool server_assigned_cookie;
bool consented_to_terms;
void parse(XML_PARSER&);
};
@ -72,7 +73,7 @@ struct CREATE_ACCOUNT_OP: public GUI_HTTP_OP {
gui_http = p;
}
virtual ~CREATE_ACCOUNT_OP(){}
int do_rpc(ACCOUNT_IN&);
int do_rpc(ACCOUNT_IN&, std::string rpc_client_name);
virtual void handle_reply(int http_op_retval);
};

View File

@ -830,7 +830,11 @@ void handle_create_account(GUI_RPC_CONN& grc) {
ACCOUNT_IN ai;
ai.parse(grc.xp);
grc.create_account_op.do_rpc(ai);
if (ai.consented_to_terms && !grc.client_name.size()) {
grc.mfout.printf("<error>&lt;name&gt; must be set in &lt;exchange_versions&gt; before using &lt;consented_to_terms/&gt;</error>\n");
return;
}
grc.create_account_op.do_rpc(ai, grc.client_name);
grc.mfout.printf("<success/>\n");
}

View File

@ -421,6 +421,7 @@ void CProjectProcessingPage::OnStateChange( CProjectProcessingPageEvent& WXUNUSE
if (pWA->m_AccountInfoPage->m_pAccountCreateCtrl->GetValue() && !pWA->GetProjectSetupCookie().size()) {
creating_account = true;
ai->consented_to_terms = pWA->GetConsentedToTerms();
// Wait until we are done processing the request.
dtStartExecutionTime = wxDateTime::Now();

View File

@ -280,7 +280,10 @@ void CTermsOfUsePage::OnPageChanging( wxWizardExEvent& event ) {
// re-enabled if the back button is pressed.
pWA->EnableNextButton();
if (event.GetDirection() == false) return;
if (event.GetDirection() == false) {
pWA->SetConsentedToTerms(false);
return;
}
if (!CHECK_CLOSINGINPROGRESS()) {
// We are leaving this page.
@ -293,6 +296,7 @@ void CTermsOfUsePage::OnPageChanging( wxWizardExEvent& event ) {
} else {
SetCredentialsAlreadyAvailable(false);
}
pWA->SetConsentedToTerms(GetUserAgrees());
}
}

View File

@ -140,6 +140,7 @@ bool CWizardAttach::Create( wxWindow* parent, wxWindowID id, const wxString& /*
m_bCredentialsDetected = false;
m_bCookieRequired = false;
m_strCookieFailureURL.Empty();
m_bConsentedToTerms = false;
CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced();

View File

@ -301,6 +301,9 @@ public:
wxString GetAccountConfirmPassword() const { return m_strAccountConfirmPassword ; }
void SetAccountConfirmPassword(wxString value) { m_strAccountConfirmPassword = value ; }
bool GetConsentedToTerms() const { return m_bConsentedToTerms ; }
void SetConsentedToTerms(bool value) { m_bConsentedToTerms = value ; }
wxString GetReturnURL() const { return m_strReturnURL ; }
void SetReturnURL(wxString value) { m_strReturnURL = value ; }
@ -374,6 +377,7 @@ public:
wxString m_strAccountUsername;
wxString m_strAccountPassword;
wxString m_strAccountConfirmPassword;
bool m_bConsentedToTerms;
wxString m_strReturnURL;
wxString m_strCookieFailureURL;
};

View File

@ -582,6 +582,7 @@ struct ACCOUNT_IN {
std::string server_cookie;
bool ldap_auth;
bool server_assigned_cookie;
bool consented_to_terms;
ACCOUNT_IN();

View File

@ -1384,6 +1384,7 @@ void ACCOUNT_IN::clear() {
server_cookie.clear();
ldap_auth = false;
server_assigned_cookie = false;
consented_to_terms = false;
}
ACCOUNT_OUT::ACCOUNT_OUT() {
@ -2377,12 +2378,14 @@ int RPC_CLIENT::create_account(ACCOUNT_IN& ai) {
" <passwd_hash>%s</passwd_hash>\n"
" <user_name>%s</user_name>\n"
" <team_name>%s</team_name>\n"
" %s"
"</create_account>\n",
ai.url.c_str(),
ai.email_addr.c_str(),
passwd_hash.c_str(),
ai.user_name.c_str(),
ai.team_name.c_str()
ai.team_name.c_str(),
ai.consented_to_terms ? "<consented_to_terms/>\n" : ""
);
buf[sizeof(buf)-1] = 0;