Fix user locks & change return strings to blah.blah.blah
All checks were successful
Server Build / publish (push) Successful in 27s
Voice Build / publish (push) Successful in 25s

This commit is contained in:
olcxja 2026-05-10 20:55:24 +02:00
commit 7da97dbeb6
6 changed files with 56 additions and 49 deletions

View file

@ -118,7 +118,7 @@ public class Requests
);
if (!createHolder.TryGetValue(serializedBody.idKey, out CreateHolder entry))
{
await context.Response.WriteAsync("Account request expired");
await context.Response.WriteAsync("error:account.creation.request.expired");
return;
}
@ -133,13 +133,13 @@ public class Requests
if (!Utils.IsValidUsername(entry.name, out string message))
{
await context.Response.WriteAsync("Username: " + message);
await context.Response.WriteAsync($"error:invalid.username.{{{message}}}");
return;
}
if (!Utils.IsValidPassword(entry.pass, out message))
{
await context.Response.WriteAsync("Password: " + message);
await context.Response.WriteAsync($"error:invalid.password.{{{message}}}");
return;
}
@ -162,14 +162,14 @@ public class Requests
);
if (!createHolder.TryGetValue(serialized.idKey, out var entry))
{
await context.Response.WriteAsync("Account request expired");
await context.Response.WriteAsync("error:account.creation.request.expired");
return;
}
if (entry.captcha.ToLower() != serialized.captcha.ToLower())
{
createHolder.TryRemove(serialized.idKey, out _);
await context.Response.WriteAsync("Incorrect captcha. Please try again");
await context.Response.WriteAsync("error:incorrect.captcha");
return;
}
@ -177,7 +177,7 @@ public class Requests
if (Fs.Exists($"{ACCOUNTS_NAME_DIR}/{lowerName}"))
{
await context.Response.WriteAsync("This username is already taken");
await context.Response.WriteAsync("error:username.taken");
return;
}
@ -185,7 +185,7 @@ public class Requests
Encoding.UTF8.GetString(await Fs.ReadFile($"{ACCOUNTS_DIR}/registration"));
if (registrationString.StartsWith("0;"))
{
await context.Response.WriteAsync("Account creation is currently disabled. Try again later");
await context.Response.WriteAsync("error:registration.disabled");
return;
}
@ -217,7 +217,7 @@ public class Requests
if (!valid)
{
await context.Response.WriteAsync(
"Account creation is currently disabled. Try again later");
"error:registration.disabled");
return;
}
}
@ -240,7 +240,7 @@ public class Requests
if (id == ulong.MaxValue)
{
await context.Response.WriteAsync(
"Server is full, cannot create new accounts. Try again later.");
"error:accounts.slots.full");
return;
}
@ -264,7 +264,7 @@ public class Requests
userLock.Release();
}
await context.Response.WriteAsync("Account created");
await context.Response.WriteAsync("success:account.created");
return;
}
}
@ -389,7 +389,7 @@ public class Requests
userLock.Release();
}
await context.Response.WriteAsync("Password changed successfully");
await context.Response.WriteAsync("success:password.changed");
return;
}
@ -444,7 +444,7 @@ public class Requests
//string publicKey = serializedBody.string1;
//string privateEncryptedKey = serializedBody.string2;
await Utils.UpdateUserKeys(id, body);
return "Keys updated successfully";
return "success:keys.updated";
}
public static async Task GetUserPublicKey(HttpContext context, Func<Task> next, IQueryCollection query, StreamReader bodyReader)
@ -565,6 +565,11 @@ public class Requests
await Room.Requests.DmCreate(id, serializedBody.string2)
, password));
break;
default:
await context.Response.WriteAsync(Encryption.Encryption.EncryptString(
$"error:unknown.request.{{{serializedBody.string1}}}"
, password));
break;
}
}
finally