Ejemplo n.º 1
0
    def change_password(self, cur_password, new_password):
        if self.username is None:
            self.send_message(
                "change_password_fail",
                reason="You need to log in to change your password.")
            return

        if not userdb.user_passwd_match(self.username, cur_password):
            self.send_message("change_password_fail",
                              reason="Your password didn't match.")
            self.logger.info(
                "Non-matching current password during password change for %s",
                self.username)
            return

        error = userdb.change_password(self.user_id, new_password)
        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 password.", self.username)
            self.send_message("change_password_done")
        else:
            self.logger.info("Failed to change username for %s: %s",
                             self.username, error)
            self.send_message("change_password_fail", reason=error)
Ejemplo n.º 2
0
    def change_password(self, cur_password, new_password):
        if not self.update_db_info():
            self.send_message("change_password_fail", reason="Account is disabled")
            return

        if self.username is None:
            self.send_message("change_password_fail",
                    reason="You need to log in to change your password.")
            return

        if self.account_restricted():
            self.send_message("change_password_fail",
                    reason="Account restricted; change password unavailable.")
            return

        if not userdb.user_passwd_match(self.username, cur_password):
            self.send_message("change_password_fail", reason = "Your password didn't match.")
            self.logger.info("Non-matching current password during password change for %s", self.username)
            return

        error = userdb.change_password(self.user_id, new_password)
        if error is None:
            self.logger.info("User %s changed password.", self.username)
            self.send_message("change_password_done")
        else:
            self.logger.info("Failed to change username for %s: %s", self.username, error)
            self.send_message("change_password_fail", reason = error)
Ejemplo n.º 3
0
 def login(self, username, password):
     real_username, fail_reason = userdb.user_passwd_match(
         username, password)
     if real_username and fail_reason is None:
         self.logger.info("User %s logging in from %s.", real_username,
                          self.request.remote_ip)
         self.do_login(real_username)
     elif fail_reason:
         self.logger.warning("Failed login for user %s: %s", real_username,
                             fail_reason)
         self.send_message("login_fail", reason=fail_reason)
     else:
         self.logger.warning("Failed login for user %s.", username)
         self.send_message("login_fail")