Skip to content

Commit 8077f5a

Browse files
Fixed Packet references for SAPI.Auth
1 parent bd18e79 commit 8077f5a

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

SAPI.Auth/Session.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public static class Session
77
{
88
public static List<SessionToken> SessionTokens = new();
99

10-
public static void GenerateSessionToken(Identity identity, Packet packet)
10+
public static void GenerateSessionToken(Identity identity, HttpListenerContext context)
1111
{
1212
SessionToken token = new()
1313
{
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using SAPI;
1+
using System.Net;
2+
using SAPI;
23
using SAPI.API.Utilities;
34
using SAPI.Auth;
45

@@ -8,18 +9,18 @@ public class AuthCheck : Endpoint
89
{
910
public override string url { get; } = "auth-check";
1011

11-
protected override void Post(ref Packet packet)
12+
protected override void Post(HttpListenerContext context, Dictionary<string, string> parameters)
1213
{
13-
Json.Fetch(out AuthExt.NewAuth auth, ref packet);
14+
Json.Fetch(out AuthExt.NewAuth auth, context);
1415
Identity identity = new()
1516
{
1617
Identifier = auth.username,
1718
Password = auth.password
1819
};
1920
if (identity.Verify())
20-
Error.Page(HttpStatus.OK, ref packet);
21+
Error.Page(HttpStatus.OK, context);
2122
else
22-
Error.Page(HttpStatus.Forbidden, ref packet);
23+
Error.Page(HttpStatus.Forbidden, context);
2324
}
2425
}
2526
}

SAPI_Testing/Endpoints/AuthExt.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,32 @@ public class AuthExt : Endpoint
1010
{
1111
public override string url { get; } = "auth-ext";
1212

13-
protected override void Get(ref Packet packet)
13+
protected override void Get(HttpListenerContext context, Dictionary<string, string> parameters)
1414
{
15-
SAPI.LLAPI.Utilities.Html.HtmlResponse("<h1>GOOD</h1>", ref packet);
15+
SAPI.LLAPI.Utilities.Html.HtmlResponse("<h1>GOOD</h1>", context);
1616
}
1717

18-
protected override void Post(ref Packet packet)
18+
protected override void Post(HttpListenerContext context, Dictionary<string, string> parameters)
1919
{
20-
Json.Fetch(out NewAuth auth, ref packet);
20+
Json.Fetch(out NewAuth auth, context);
2121

2222
Identity identity = new()
2323
{
2424
Identifier = auth.username,
2525
Password = auth.password
2626
};
2727
if (identity.Create())
28-
Error.Page(HttpStatus.OK, ref packet);
28+
Error.Page(HttpStatus.OK, context);
2929
else
30-
Error.Page(HttpStatus.BadRequest, ref packet);
30+
Error.Page(HttpStatus.BadRequest, context);
3131

32-
Session.GenerateSessionToken(identity, packet);
32+
Session.GenerateSessionToken(identity, context);
3333

3434
Cookie cookie = new("test", "test")
3535
{
3636
Expires = DateTime.UtcNow.AddDays(1)
3737
};
38-
packet.Response.AppendCookie(cookie);
38+
context.Response.AppendCookie(cookie);
3939
}
4040

4141
public record NewAuth(string username, string password);

0 commit comments

Comments
 (0)