fixes refreshed PoW tokens not actually being reactivated

This commit is contained in:
nai-degen 2024-09-15 18:01:23 -05:00
parent 7a4a16dd2f
commit 6e97e036b2
2 changed files with 8 additions and 4 deletions

View File

@ -299,10 +299,11 @@ export function disableUser(token: string, reason?: string) {
if (!user) return; if (!user) return;
user.disabledAt = Date.now(); user.disabledAt = Date.now();
user.disabledReason = reason; user.disabledReason = reason;
if (user.meta) { if (!user.meta) {
// manually banned tokens cannot be refreshed user.meta = {};
user.meta.refreshable = false;
} }
// manually banned tokens cannot be refreshed
user.meta.refreshable = false;
usersToFlush.add(token); usersToFlush.add(token);
} }
@ -418,7 +419,8 @@ function getModelFamilyForQuotaUsage(
// differentiate between Azure and OpenAI variants of the same model. // differentiate between Azure and OpenAI variants of the same model.
if (model.includes("azure")) return getAzureOpenAIModelFamily(model); if (model.includes("azure")) return getAzureOpenAIModelFamily(model);
if (model.includes("anthropic.")) return getAwsBedrockModelFamily(model); if (model.includes("anthropic.")) return getAwsBedrockModelFamily(model);
if (model.startsWith("claude-") && model.includes("@")) return getGcpModelFamily(model); if (model.startsWith("claude-") && model.includes("@"))
return getGcpModelFamily(model);
switch (api) { switch (api) {
case "openai": case "openai":

View File

@ -300,6 +300,8 @@ router.post("/verify", async (req, res) => {
const user = getUser(challenge.token); const user = getUser(challenge.token);
if (user) { if (user) {
user.expiresAt = Date.now() + config.powTokenHours * 60 * 60 * 1000; user.expiresAt = Date.now() + config.powTokenHours * 60 * 60 * 1000;
user.disabledAt = undefined;
user.disabledReason = undefined;
upsertUser(user); upsertUser(user);
req.log.info( req.log.info(
{ token: `...${challenge.token.slice(-5)}` }, { token: `...${challenge.token.slice(-5)}` },