|
@@ -23,6 +23,14 @@ class AccountActivator(_AccountActivator):
|
|
self.users = users
|
|
self.users = users
|
|
|
|
|
|
def initiate_account_activation(self, email):
|
|
def initiate_account_activation(self, email):
|
|
|
|
+ """
|
|
|
|
+ Looks a user up via email and sends an activation token.
|
|
|
|
+
|
|
|
|
+ Will raise a
|
|
|
|
+ :class:`ValidationError<flaskbb.core.exceptions.ValidationError>`
|
|
|
|
+ if either the email doesn't exist in the application or the account
|
|
|
|
+ tied to the email is already activated.
|
|
|
|
+ """
|
|
user = self.users.query.filter_by(email=email).first()
|
|
user = self.users.query.filter_by(email=email).first()
|
|
|
|
|
|
if user is None:
|
|
if user is None:
|
|
@@ -40,6 +48,18 @@ class AccountActivator(_AccountActivator):
|
|
)
|
|
)
|
|
|
|
|
|
def activate_account(self, token):
|
|
def activate_account(self, token):
|
|
|
|
+ """
|
|
|
|
+ Activates an account based on the supplied token.
|
|
|
|
+
|
|
|
|
+ Will raise
|
|
|
|
+ :class:`TokenError<flaskbb.core.tokens.TokenError>` if the supplied
|
|
|
|
+ token is not an account activation token and a
|
|
|
|
+ :class:`ValidationError<flaskbb.core.exceptions.ValidationError>`
|
|
|
|
+ if the account is already activated.
|
|
|
|
+
|
|
|
|
+ Otherwise marks the account as activated.
|
|
|
|
+ """
|
|
|
|
+
|
|
token = self.token_serializer.loads(token)
|
|
token = self.token_serializer.loads(token)
|
|
if token.operation != TokenActions.ACTIVATE_ACCOUNT:
|
|
if token.operation != TokenActions.ACTIVATE_ACCOUNT:
|
|
raise TokenError.invalid()
|
|
raise TokenError.invalid()
|