Skip to content

Commit

Permalink
Add dummy implementation of CheckPasswordAction
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaioru committed Aug 5, 2022
1 parent 293b8e7 commit 7df7ac9
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,61 @@
using Edelstein.Protocol.Gameplay.Stages.Login.Messages;
using Edelstein.Common.Gameplay.Packets;
using Edelstein.Common.Gameplay.Stages.Login.Types;
using Edelstein.Common.Network.Packets;
using Edelstein.Common.Services.Auth.Contracts;
using Edelstein.Protocol.Gameplay.Stages.Login.Messages;
using Edelstein.Protocol.Services.Auth;
using Edelstein.Protocol.Services.Auth.Contracts;
using Edelstein.Protocol.Util.Pipelines;
using Microsoft.Extensions.Logging;

namespace Edelstein.Common.Gameplay.Stages.Login.Actions;

public class CheckPasswordAction : IPipelineAction<ICheckPassword>
{
private readonly IAuthService _auth;
private readonly ILogger _logger;

public CheckPasswordAction(ILogger<CheckPasswordAction> logger) => _logger = logger;
public CheckPasswordAction(ILogger<CheckPasswordAction> logger, IAuthService auth)
{
_logger = logger;
_auth = auth;
}

public Task Handle(IPipelineContext ctx, ICheckPassword message)
public async Task Handle(IPipelineContext ctx, ICheckPassword message)
{
_logger.LogInformation(
"Login attempt with username: {Username}, password: {Password}",
message.Username, message.Password
);
return Task.CompletedTask;
var response = await _auth.Login(new AuthLoginRequest(message.Username, message.Password));
var result = response.Result switch
{
AuthLoginResult.Success => LoginResult.Success,
AuthLoginResult.FailedInvalidUsername => LoginResult.NotRegistered,
AuthLoginResult.FailedInvalidPassword => LoginResult.IncorrectPassword,
_ => LoginResult.Unknown
};
var packet = new PacketOut(PacketSendOperations.CheckPasswordResult);

packet.WriteByte((byte)result);
packet.WriteByte(0);
packet.WriteInt(0);

if (result == LoginResult.Success)
{
packet.WriteInt(1);
packet.WriteByte(0);
packet.WriteByte(0);
packet.WriteShort(0);
packet.WriteByte(0); // nCountryID
packet.WriteString(message.Username); // sNexonClubID
packet.WriteByte(0); // nPurchaseEXP
packet.WriteByte(0); // ChatUnblockReason
packet.WriteLong(0); // dtChatUnblockDate
packet.WriteLong(0); // dtRegisterDate
packet.WriteInt(4); // nNumOfCharacter
packet.WriteByte(1); // v44
packet.WriteByte(0); // sMsg

packet.WriteLong(0);
}

await message.User.Dispatch(packet);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<ProjectReference Include="..\..\protocol\Edelstein.Protocol.Gameplay.Stages.Login\Edelstein.Protocol.Gameplay.Stages.Login.csproj" />
<ProjectReference Include="..\..\protocol\Edelstein.Protocol.Util.Pipelines\Edelstein.Protocol.Util.Pipelines.csproj" />
<ProjectReference Include="..\Edelstein.Common.Gameplay\Edelstein.Common.Gameplay.csproj" />
<ProjectReference Include="..\Edelstein.Common.Network\Edelstein.Common.Network.csproj" />
<ProjectReference Include="..\Edelstein.Common.Services.Auth\Edelstein.Common.Services.Auth.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
namespace Edelstein.Common.Gameplay.Stages.Login.Types;

public enum LoginResult : byte
{
ProcFail = byte.MaxValue,
Success = 0x0,
TempBlocked = 0x1,
Blocked = 0x2,
Abandoned = 0x3,
IncorrectPassword = 0x4,
NotRegistered = 0x5,
DBFail = 0x6,
AlreadyConnected = 0x7,
NotConnectableWorld = 0x8,
Unknown = 0x9,
Timeout = 0xA,
NotAdult = 0xB,
AuthFail = 0xC,
ImpossibleIP = 0xD,
NotAuthorizedNexonID = 0xE,
NoNexonID = 0xF,
NotAuthorized = 0x10,
InvalidRegionInfo = 0x11,
InvalidBirthDate = 0x12,
PassportSuspended = 0x13,
IncorrectSSN2 = 0x14,
WebAuthNeeded = 0x15,
DeleteCharacterFailedOnGuildMaster = 0x16,
NotagreedEULA = 0x17,
DeleteCharacterFailedEngaged = 0x18,
IncorrectSPW = 0x14,
SamePasswordAndSPW = 0x16,
SamePincodeAndSPW = 0x17,
RegisterLimitedIP = 0x19,
RequestedCharacterTransfer = 0x1A,
CashUserCannotUseSimpleClient = 0x1B,
DeleteCharacterFailedOnFamily = 0x1D,
InvalidCharacterName = 0x1E,
IncorrectSSN = 0x1F,
SSNConfirmFailed = 0x20,
SSNNotConfirmed = 0x21,
WorldTooBusy = 0x22,
OTPReissuing = 0x23,
OTPInfoNotExist = 0x24
}

0 comments on commit 7df7ac9

Please sign in to comment.