def reset_token_commands(args): if args.clear_reset: username = args.clear_reset else: username = args.reset user_info = userdb.get_user_info(username) if not user_info: err_exit("Reset/clear password failed; invalid user: %s" % username) # don't crash on the default config if config.get('lobby_url') is None: config.set('lobby_url', "[insert lobby url here]") if args.clear_reset: ok, msg = userdb.clear_password_token(username) if not ok: err_exit("Error clearing password reset token for %s: %s" % (username, msg)) else: print("Password reset token cleared for account '%s'." % username) else: ok, msg = userdb.generate_forgot_password(username) if not ok: err_exit("Error generating password reset token for %s: %s" % (username, msg)) else: if not user_info[1]: logging.warning("No email set for account '%s', use caution!" % username) print("Setting a password reset token on account '%s'." % username) print("Email: %s\nMessage body to send to user:\n%s\n" % (user_info[1], msg))
def admin_pw_reset_clear(self, username): ok, err = userdb.clear_password_token(username) if ok: self.logger.info( "Admin user '%s' cleared the reset token on account '%s'", self.username, username) else: self.logger.info("Error trying to clear reset token for '%s': %s", username, err)