Ejemplo n.º 1
0
            public UserAccount Get(string name, string pass)
            {
                for (var i = 0; i < accounts.Count; i++)
                {
                    if (accounts[i].Name.Equals(name, StringComparison.OrdinalIgnoreCase))
                    {
                        return(accounts[i]);
                    }
                }
                var acc = new UserAccount(accounts.Count, name, AccountUtility.CalculateHash(pass), "*****@*****.**", false, AccountPrivilege.Player, DateTime.Now, 0);

                accounts.Add(acc);
                return(acc);
            }
Ejemplo n.º 2
0
    void HandleAuthChallenge(NetworkPacket m)
    {
        var db            = ServiceContainer.GetService <IDatabase>();
        var clientVersion = (int)m.ReadUInt32();
        var name          = m.ReadString();
        var password      = m.ReadString();

        if (SupportedClientVersion != clientVersion)
        {
            SendAuthResult(m.Connection, eLoginRequestResult.LRR_INVALID_REVISION);
            return;
        }
        var acc = db.Accounts.Get(name, password);

        if (acc == null)
        {
            SendAuthResult(m.Connection, eLoginRequestResult.LRR_INVALID_USERNAME);
            return;
        }
        if (acc.Banned)
        {
            SendAuthResult(m.Connection, eLoginRequestResult.LRR_BANNED_ACCOUNT);
            return;
        }
        if (ServiceContainer.GetService <ISessionHandler>().Get <GameSession>(m.Connection) != null)
        {
            Debug.LogWarning(string.Format("Account '{0}' - Gamesession already active", acc.Name));
            SendAuthResult(m.Connection, eLoginRequestResult.LRR_LOGIN_ADD_FAILED);
            return;
        }
        if (acc.PasswordHash != AccountUtility.CalculateHash(password))
        {
            SendAuthResult(m.Connection, eLoginRequestResult.LRR_INVALID_PASSWORD);
            return;
        }
        var session = new LoginSession(m.Connection, acc);

        SendAuthResult(m.Connection, eLoginRequestResult.LRR_NONE);
        ServiceContainer.GetService <ISessionHandler>().Begin(session);
    }