Pusher service basis

This commit is contained in:
2025-07-12 22:15:18 +08:00
parent 33f56c4ef5
commit e1b47bc7d1
22 changed files with 1117 additions and 104 deletions

View File

@ -0,0 +1,27 @@
using DysonNetwork.Shared.Proto;
using Grpc.Core;
using Microsoft.EntityFrameworkCore;
namespace DysonNetwork.Pass.Auth;
public class AuthServiceGrpc(AuthService authService, AppDatabase db) : Shared.Proto.AuthService
{
public async Task<Shared.Proto.AuthSession> Authenticate(AuthenticateRequest request, ServerCallContext context)
{
if (!authService.ValidateToken(request.Token, out var sessionId))
{
throw new RpcException(new Status(StatusCode.Unauthenticated, "Invalid token."));
}
var session = await db.AuthSessions
.AsNoTracking()
.FirstOrDefaultAsync(s => s.Id == sessionId);
if (session == null)
{
throw new RpcException(new Status(StatusCode.NotFound, "Session not found."));
}
return session.ToProtoValue();
}
}