From: Michael Tremer Date: Tue, 26 Nov 2024 17:13:51 +0000 (+0000) Subject: accounts: Always ask for consent of promotional emails X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=eac4a2c85bbecf6baf5fd4585a84bed6a97a342f;p=ipfire.org.git accounts: Always ask for consent of promotional emails Signed-off-by: Michael Tremer --- diff --git a/src/backend/accounts.py b/src/backend/accounts.py index 31f904f7..567619af 100644 --- a/src/backend/accounts.py +++ b/src/backend/accounts.py @@ -479,9 +479,23 @@ class Accounts(Object): first_name=first_name, last_name=last_name) def activate(self, uid, activation_code): - res = self.db.get("DELETE FROM account_activations \ - WHERE uid = %s AND activation_code = %s AND expires_at > NOW() \ - RETURNING *", uid, activation_code) + """ + Activates a user + """ + # Delete the activation code + res = self.db.get(""" + DELETE FROM + account_activations + WHERE + uid = %s + AND + activation_code = %s + AND + expires_at > CURRENT_TIMESTAMP + RETURNING + * + """, uid, activation_code, + ) # Return nothing when account was not found if not res: @@ -493,13 +507,13 @@ class Accounts(Object): return account # Create a new account on the LDAP database - account = self.create(uid, res.email, - first_name=res.first_name, last_name=res.last_name, - country_code=res.country_code) - - # Non-EU users do not need to consent to promo emails - if account.country_code and not account.country_code in countries.EU_COUNTRIES: - account.consents_to_promotional_emails = True + account = self.create( + uid = uid, + email = res.email, + first_name = res.first_name, + last_name = res.last_name, + country_code = res.country_code, + ) # Send email about account registration self.backend.messages.send_template("people/messages/new-account",