-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add dummy implementation of CheckPasswordAction
- Loading branch information
Showing
3 changed files
with
95 additions
and
8 deletions.
There are no files selected for viewing
56 changes: 48 additions & 8 deletions
56
src/common/Edelstein.Common.Gameplay.Stages.Login/Actions/CheckPasswordAction.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/common/Edelstein.Common.Gameplay.Stages.Login/Types/LoginResult.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |