TigerEmu/Communication/Messages/Incoming/Handshake/SsoEvent.cs

34 lines
974 B
C#
Raw Permalink Normal View History

2023-11-10 13:55:42 +00:00
using Tiger.Communication.Messages.Interfaces;
using Tiger.Communication.Messages.Outgoing.Handshake;
using Tiger.Communication.Messages.Types;
using Tiger.Game.Habbos;
using Tiger.Networking.Game.Sessions;
using Tiger.Storage;
namespace Tiger.Communication.Messages.Incoming.Handshake;
public class SsoEvent : IMessageEvent
{
private readonly IRepository<Habbo> _habboRepository;
public SsoEvent(IRepository<Habbo> habboRepository)
{
_habboRepository = habboRepository;
}
public IncomingHeaders Header => IncomingHeaders.Sso;
public async Task HandleAsync(GameSession gameSession, ClientMessage request)
{
var habbo = await _habboRepository.FindOneByAsync(h => h.SsoTicket == request.ReadString());
if (habbo == null)
{
await gameSession.CloseAsync();
return;
}
gameSession.Habbo = habbo;
await gameSession.SendComposerAsync(new LoginOkComposer());
}
}