Esempio n. 1
0
 def validate(self):
     ucontr = UserController()
     validated = super().validate()
     if ucontr.read(nickname=self.nickname.data).count():
         self.nickname.errors.append("Nickname already taken")
         validated = False
     if self.nickname.data != User.make_valid_nickname(self.nickname.data):
         self.nickname.errors.append(
             lazy_gettext(
                 "This nickname has invalid characters. "
                 "Please use letters, numbers, dots and underscores only."))
         validated = False
     return validated
Esempio n. 2
0
def confirm_account(token=None):
    """
    Confirm the account of a user.
    """
    user_contr = UserController()
    user, nickname = None, None
    if token != "":
        nickname = confirm_token(token)
    if nickname:
        user = user_contr.read(nickname=nickname).first()
    if user is not None:
        user_contr.update({"id": user.id}, {"is_active": True})
        flash(gettext("Your account has been confirmed."), "success")
    else:
        flash(gettext("Impossible to confirm this account."), "danger")
    return redirect(url_for("login"))