Auth fixes
This commit is contained in:
parent
c58d3dbcdf
commit
7ca4b5ceb3
3 changed files with 34 additions and 11 deletions
|
|
@ -30,11 +30,10 @@ public class Requests
|
|||
return;
|
||||
}
|
||||
|
||||
string body = await LoadBody(bodyReader);
|
||||
string id = await Utils.IdFromName(username);
|
||||
string password = await Utils.GetPassword(id);
|
||||
body = await Utils.NonceDecryptBody(username, password, body);
|
||||
string auth = await Utils.Auth(id, password, body);
|
||||
secret = await Utils.NonceDecryptBody(username, password, secret);
|
||||
string auth = await Utils.Auth(id, password, secret);
|
||||
if (auth != Utils.LOGIN_SUCCESS)
|
||||
{
|
||||
await context.Response.WriteAsync(auth);
|
||||
|
|
@ -71,6 +70,7 @@ public class Requests
|
|||
switch (step)
|
||||
{
|
||||
case "init":
|
||||
{
|
||||
foreach (var kvp in createHolder) // czyszczenie nieaktywnych od 2 minut requestow
|
||||
{
|
||||
if (kvp.Value.date < DateTimeOffset.UtcNow.AddMinutes(-2))
|
||||
|
|
@ -107,7 +107,9 @@ public class Requests
|
|||
|
||||
await context.Response.WriteAsync(serializedPayload);
|
||||
return;
|
||||
}
|
||||
case "register":
|
||||
{
|
||||
string body = await LoadBody(bodyReader);
|
||||
|
||||
KeyExchangePayloadClient serializedBody = JsonSerializer.Deserialize(
|
||||
|
|
@ -149,14 +151,16 @@ public class Requests
|
|||
await context.Response.Body.WriteAsync(captchaResult.ImageBytes, 0,
|
||||
captchaResult.ImageBytes.Length);
|
||||
return;
|
||||
}
|
||||
case "finish":
|
||||
body = await LoadBody(bodyReader);
|
||||
|
||||
{
|
||||
string body = await LoadBody(bodyReader);
|
||||
|
||||
CaptchaPayloadClient serialized = JsonSerializer.Deserialize(
|
||||
body,
|
||||
AppJsonSerializerContext.Default.CaptchaPayloadClient
|
||||
);
|
||||
if (!createHolder.TryGetValue(serialized.idKey, out entry))
|
||||
if (!createHolder.TryGetValue(serialized.idKey, out var entry))
|
||||
{
|
||||
await context.Response.WriteAsync("Account request expired");
|
||||
return;
|
||||
|
|
@ -262,6 +266,7 @@ public class Requests
|
|||
|
||||
await context.Response.WriteAsync("Account created");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
await next();
|
||||
|
|
@ -368,7 +373,7 @@ public class Requests
|
|||
string id = await Utils.IdFromName(username);
|
||||
string body = await LoadBody(bodyReader);
|
||||
string password = await Utils.GetPassword(id);
|
||||
string newPass = await Utils.NonceDecryptBody(username, password, body);
|
||||
string newPass = await Utils.NonceDecryptBody(username, password, body, false);
|
||||
secret = await Utils.NonceDecryptBody(username, password, secret);
|
||||
|
||||
string auth = await Utils.Auth(id, password, secret);
|
||||
|
|
@ -416,7 +421,9 @@ public class Requests
|
|||
string id = await Utils.IdFromName(username);
|
||||
string body = await LoadBody(bodyReader);
|
||||
string password = await Utils.GetPassword(id);
|
||||
body = await Utils.NonceDecryptBody(username, password, body);
|
||||
|
||||
|
||||
body = await Utils.NonceDecryptBody(username, password, body, false);
|
||||
secret = await Utils.NonceDecryptBody(username, password, secret);
|
||||
|
||||
string auth = await Utils.Auth(id, secret, password);
|
||||
|
|
@ -518,7 +525,7 @@ public class Requests
|
|||
string id = await Utils.IdFromName(username);
|
||||
string body = await LoadBody(bodyReader);
|
||||
string password = await Utils.GetPassword(id);
|
||||
body = await Utils.NonceDecryptBody(username, password, body);
|
||||
body = await Utils.NonceDecryptBody(username, password, body, false);
|
||||
secret = await Utils.NonceDecryptBody(username, password, secret);
|
||||
|
||||
Universal2String serializedBody = JsonSerializer.Deserialize(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue