Files
AobaV2/AobaServer/Services/AobaAuthService.cs
Amatsugu 7427bbb576
All checks were successful
Build and Push Image / build-and-push (push) Successful in 5m24s
refactor proto files + added metrics token
2025-07-06 01:28:52 -04:00

41 lines
857 B
C#

using Aoba.RPC.Auth;
using AobaCore.Models;
using AobaCore.Services;
using AobaServer.Models;
using AobaServer.Utils;
using Grpc.Core;
using Microsoft.AspNetCore.Authorization;
using Aoba.RPC;
namespace AobaServer.Services;
public class AobaAuthService(AccountsService accountsService, AuthInfo authInfo) : AuthRpc.AuthRpcBase
{
public override async Task<LoginResponse> Login(Credentials request, ServerCallContext context)
{
var user = await accountsService.VerifyLoginAsync(request.User, request.Password, context.CancellationToken);
if (user == null)
return new LoginResponse
{
Error = new LoginError
{
Message = "Invalid login credentials"
}
};
var token = user.GetToken(authInfo);
return new LoginResponse
{
Jwt = new ()
{
Token = token
}
};
}
}