Exemplo n.º 1
0
    def change_email(self, email):
        if not self.update_db_info():
            self.send_message("change_email_fail",
                              reason="Account is disabled")
            return

        if self.username is None:
            self.send_message("change_email_fail",
                              reason="You need to log in to change your email")
            return
        if self.account_restricted():
            self.send_message(
                "change_email_fail",
                reason="Account restricted; change email unavailable.")
            return
        error = userdb.change_email(self.user_id, email)
        if error is None:
            self.update_db_info()
            self.logger.info("User %s changed email to %s.", self.username,
                             self.user_email if self.user_email else "null")
            self.send_message("change_email_done", email=self.user_email)
        else:
            self.logger.info("Failed to change username for %s: %s",
                             self.username, error)
            self.send_message("change_email_fail", reason=error)
Exemplo n.º 2
0
 def change_email(self, email):
     if self.username is None:
         self.send_message("change_email_fail",
                           reason="You need to log in to change your email")
         return
     error = userdb.change_email(self.user_id, email)
     if error is None:
         self.user_id, self.user_email, self.user_flags = userdb.get_user_info(
             self.username)
         self.logger.info("User %s changed email to %s.", self.username,
                          email if email else "null")
         self.send_message("change_email_done", email=email)
     else:
         self.logger.info("Failed to change username for %s: %s",
                          self.username, error)
         self.send_message("change_email_fail", reason=error)