53 lines
1.8 KiB
C#
53 lines
1.8 KiB
C#
using Tiger.Communication.Messages.Interfaces;
|
|
using Tiger.Communication.Messages.Outgoing.Generic.Alerts;
|
|
using Tiger.Communication.Messages.Outgoing.Handshake;
|
|
using Tiger.Communication.Messages.Types;
|
|
using Tiger.Game.Habbos;
|
|
using Tiger.Game.Settings;
|
|
using Tiger.Networking.Game.Sessions;
|
|
using Tiger.Storage;
|
|
|
|
namespace Tiger.Communication.Messages.Incoming.Handshake;
|
|
|
|
public class SsoTicketEvent : IMessageEvent
|
|
{
|
|
private readonly IRepository<Habbo> _habboRepository;
|
|
private readonly IGameSessionManager _gameSessionManager;
|
|
private readonly ISettingManager _settingManager;
|
|
|
|
public SsoTicketEvent(IRepository<Habbo> habboRepository, IGameSessionManager gameSessionManager, ISettingManager settingManager)
|
|
{
|
|
_habboRepository = habboRepository;
|
|
_gameSessionManager = gameSessionManager;
|
|
_settingManager = settingManager;
|
|
}
|
|
|
|
public IncomingHeaders Header => IncomingHeaders.SSoTicketEvent;
|
|
|
|
public async Task HandleAsync(GameSession gameSession, ClientMessage request)
|
|
{
|
|
var sso = request.ReadString();
|
|
|
|
if (sso == null)
|
|
{
|
|
await _gameSessionManager.CloseAsync("Malformed packet", gameSession);
|
|
return;
|
|
}
|
|
|
|
var habbo = await _habboRepository.FindOneByAsync(h => h.SsoTicket == sso);
|
|
|
|
if (habbo == null)
|
|
{
|
|
await _gameSessionManager.CloseAsync("User not found", gameSession);
|
|
return;
|
|
}
|
|
|
|
gameSession.Habbo = habbo;
|
|
|
|
await gameSession.SendComposerAsync(new AuthenticationOkMessageComposer());
|
|
await gameSession.SendComposerAsync(new HabboBroadcastMessageComposer(
|
|
_settingManager.GetSetting<string>("welcome.message")
|
|
.Replace("{user}", gameSession.Habbo.Username)
|
|
));
|
|
}
|
|
} |