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:
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",