]> git.ipfire.org Git - ipfire.org.git/commitdiff
accounts: Always ask for consent of promotional emails
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 26 Nov 2024 17:13:51 +0000 (17:13 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 26 Nov 2024 17:13:51 +0000 (17:13 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/backend/accounts.py

index 31f904f751e6bf5d97f61e3681aadfabfa4f3a4d..567619af1d9f3240e3e9517996719db30847acc9 100644 (file)
@@ -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",