chore: add csharpier to husky, format backend with csharpier
This commit is contained in:
parent
5fab66444f
commit
7f971e8549
73 changed files with 2098 additions and 1048 deletions
|
@ -17,7 +17,9 @@ public class AuthenticationMiddleware(DatabaseContext db) : IMiddleware
|
|||
return;
|
||||
}
|
||||
|
||||
if (!AuthUtils.TryParseToken(ctx.Request.Headers.Authorization.ToString(), out var rawToken))
|
||||
if (
|
||||
!AuthUtils.TryParseToken(ctx.Request.Headers.Authorization.ToString(), out var rawToken)
|
||||
)
|
||||
{
|
||||
await next(ctx);
|
||||
return;
|
||||
|
@ -40,6 +42,7 @@ public static class HttpContextExtensions
|
|||
private const string Key = "token";
|
||||
|
||||
public static void SetToken(this HttpContext ctx, Token token) => ctx.Items.Add(Key, token);
|
||||
|
||||
public static User? GetUser(this HttpContext ctx) => ctx.GetToken()?.User;
|
||||
|
||||
public static User GetUserOrThrow(this HttpContext ctx) =>
|
||||
|
@ -54,4 +57,4 @@ public static class HttpContextExtensions
|
|||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
|
||||
public class AuthenticateAttribute : Attribute;
|
||||
public class AuthenticateAttribute : Attribute;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue