Exemplo n.º 1
0
        public void OnAccountInfoRequest(CM_ACCOUNT_INFO_REQUEST p)
        {
            SM_ACCOUNT_INFO p1 = new SM_ACCOUNT_INFO()
            {
                SessionID = p.SessionID
            };

            Logger.Log.Info(string.Format(this + ":Player:{0} is trying to login", p.Username));
            AccountLoginResult res = AccountDB.Instance.GetAccountID(p.Username, out uint accountID);

            switch (res)
            {
            case AccountLoginResult.OK:
                p1.Result  = AccountLoginResult.OK;
                p1.Account = AccountCache.Instance[accountID];
                break;

            case AccountLoginResult.NO_SUCH_ACCOUNT:
                p1.Result = AccountLoginResult.NO_SUCH_ACCOUNT;
                break;

            case AccountLoginResult.DB_ERROR:
                p1.Result = AccountLoginResult.DB_ERROR;
                break;
            }
            Logger.Log.Info(string.Format("Login result:{0}", res));
            Network.SendPacket(p1);
        }
Exemplo n.º 2
0
    public void OnLoginResult(int result, string accountId)
    {
        try
        {
            // mark account login
            GfxSystem.PublishGfxEvent("ge_enable_accountlogin", "ui");

            // close connection window
            LogicSystem.EventChannelForGfx.Publish("ge_ui_connect_hint", "ui", true, false);

            // vairy login result
            AccountLoginResult ret = (AccountLoginResult)result;
            if (ret == AccountLoginResult.Success)
            {
                NormLog.Instance.UpdateUserid(accountId);
            }
            else if (ret == AccountLoginResult.FirstLogin)
            {
                UIManager.Instance.HideWindowByName("LoginPrefab");
                UnityEngine.GameObject go = UIManager.Instance.GetWindowGoByName("Verification");
                if (null != go)
                {
                    go.GetComponent <UIVerification>().InitOpenType(UIVerification.OpenType.Verification);
                }
                UIManager.Instance.ShowWindowByName("Verification");
                NormLog.Instance.UpdateUserid(accountId);
            }
            // login failed, back to login scene
            else
            {
                // get description of login result
                string chn_desc = string.Empty;
                if (ret == AccountLoginResult.Banned)
                {
                    chn_desc = ArkCrossEngine.StrDictionaryProvider.Instance.GetDictString(209);
                }
                else if (ret == AccountLoginResult.AlreadyOnline)
                {
                    chn_desc = ArkCrossEngine.StrDictionaryProvider.Instance.GetDictString(210);
                }
                else
                {
                    chn_desc = ArkCrossEngine.StrDictionaryProvider.Instance.GetDictString(208);
                }
                string reloginTip = ArkCrossEngine.StrDictionaryProvider.Instance.GetDictString(211);

                // display YesOrNo dialog, call relogin if needed
                LogicSystem.EventChannelForGfx.Publish("ge_show_dialog", "ui", chn_desc, reloginTip, null, null, (MyAction <int>)OnRelogin, false);

                // close socket connection
                LogicSystem.PublishLogicEvent("ge_stop_login", "lobby");
            }
            NormLog.Instance.Record(GameEventCode.VerifyResult);
        }
        catch (Exception ex)
        {
            ArkCrossEngine.LogicSystem.LogFromGfx("[Error]:Exception:{0}\n{1}", ex.Message, ex.StackTrace);
        }
    }
Exemplo n.º 3
0
        public async Task <AccountLoginResult> PostLoginAccount([FromBody] LoginAccountRequest loginAccountRequest)
        {
            Account account = await _accountRepository.LoginAccount(loginAccountRequest.Email, loginAccountRequest.Password);

            AccountLoginResult accountLoginResult = new AccountLoginResult();

            accountLoginResult.Token   = _tokenJwtService.GenerateToken(account);
            accountLoginResult.Expires = DateTime.UtcNow.AddHours(int.Parse(AppSettingsProvider.Settings["TimeExpirationTokenJwtBearer"]));
            accountLoginResult.Type    = "Bearer";

            return(accountLoginResult);
        }
Exemplo n.º 4
0
        public void OnAccountInfo(AccountLoginResult res, Account account)
        {
            if (res == AccountLoginResult.NO_SUCH_ACCOUNT)
            {
                Logger.Log.Info("Login Result:" + res.ToString());
            }

            switch (res)
            {
            case AccountLoginResult.OK:
            {
                this.account = account;
                Network.Crypt.KeyExchange.MakePrivateKey();
                ((BNSKeyExchange)Network.Crypt.KeyExchange).Username = account.UserName;
                ((BNSKeyExchange)Network.Crypt.KeyExchange).Password = account.Password;
                byte[] exchange           = Network.Crypt.KeyExchange.GetKeyExchangeBytes(Mode.Server);
                byte[] session            = ((BNSKeyExchange)Network.Crypt.KeyExchange).Session.getBytes();
                System.IO.MemoryStream ms = new System.IO.MemoryStream();
                System.IO.BinaryWriter bw = new System.IO.BinaryWriter(ms);
                bw.Write(session.Length);
                bw.Write(session);
                bw.Write(exchange.Length);
                bw.Write(exchange);
                string         key = string.Format("<Reply>\n<KeyData>{0}</KeyData>\n</Reply>\n", Convert.ToBase64String(ms.ToArray()));
                BNSLoginPacket p   = new BNSLoginPacket()
                {
                    Command = "STS/1.0 200 OK",
                    Serial  = loginSerial,
                    Content = key
                };
                p.WritePacket();
                Network.SendPacket(p);
            }
            break;

            case AccountLoginResult.NO_SUCH_ACCOUNT:
            case AccountLoginResult.DB_ERROR:
            {
                BNSLoginPacket p = new BNSLoginPacket()
                {
                    Command = "STS/1.0 400 ErrAccountNotFound",
                    Serial  = loginSerial,
                    Content = "<Error code=\"3002\" server=\"1008\" module=\"1\" line=\"458\"/>\n"
                };
                p.WritePacket();
                Network.SendPacket(p);
            }
            break;
            }
        }
Exemplo n.º 5
0
        static void HandleFailedLogin(IIPSocket conn, AccountLoginResult loginResult, string name)
        {
            // Get the error message
            switch (loginResult)
            {
            case AccountLoginResult.AccountInUse:
                if (log.IsInfoEnabled)
                {
                    log.InfoFormat("Login for account `{0}` failed: Account in use.", name);
                }
                conn.Disconnect(GameMessage.LoginAccountInUse);
                break;

            case AccountLoginResult.InvalidName:
                if (log.IsInfoEnabled)
                {
                    log.InfoFormat("Login for account `{0}` failed: Invalid name.", name);
                }
                conn.Disconnect(GameMessage.LoginInvalidName);
                break;

            case AccountLoginResult.InvalidPassword:
                if (log.IsInfoEnabled)
                {
                    log.InfoFormat("Login for account `{0}` failed: Incorrect password.", name);
                }
                conn.Disconnect(GameMessage.LoginInvalidPassword);
                break;

            default:
                // If the value is undefined, just say its an invalid name
                const string errmsg = "Invalid AccountLoginResult value `{0}`.";
                if (log.IsErrorEnabled)
                {
                    log.ErrorFormat(errmsg, loginResult);
                }
                Debug.Fail(string.Format(errmsg, loginResult));
                conn.Disconnect(GameMessage.LoginInvalidName);
                break;
            }
        }
Exemplo n.º 6
0
 public void OnAccountLoginResult(AccountLoginResult result)
 {
     lastLoginRes = result;
     if (result == AccountLoginResult.OK)
     {
         account.LastLoginTime = DateTime.Now;
         account.LastLoginIP   = Network.Socket.RemoteEndPoint.ToString().Split(':')[0];
         System.IO.MemoryStream ms = new System.IO.MemoryStream();
         System.IO.BinaryWriter bw = new System.IO.BinaryWriter(ms);
         bw.Write(32);
         bw.Write(Convert.FromBase64String(checkHash));
         string         res = Convert.ToBase64String(ms.ToArray());
         string         key = string.Format("<Reply>\n<KeyData>{0}</KeyData>\n</Reply>\n", res);
         BNSLoginPacket p   = new BNSLoginPacket()
         {
             Command = "STS/1.0 200 OK",
             Serial  = loginSerial,
             Content = key,
             Encrypt = false
         };
         p.WritePacket();
         Network.SendPacket(p);
         Logger.Log.Info(account.UserName + " login successful!");
     }
     else
     {
         BNSLoginPacket p = new BNSLoginPacket()
         {
             Command = "STS/1.0 400 ErrBadPasswd",//should be already log in
             Serial  = loginSerial,
             Content = "<Error code=\"11\" server=\"1012\" module=\"1\" line=\"1683\"/>\n",
             Encrypt = false
         };
         p.WritePacket();
         Network.SendPacket(p);
         Logger.Log.Info("Login result for " + account.UserName + ": ALREADY_LOG_IN");
         AccountSession.Instance.AccountLogout(account.AccountID, this);
     }
 }
Exemplo n.º 7
0
 protected override void OnAccountLoginResult(LoginSession client, AccountLoginResult result)
 {
     client.OnAccountLoginResult(result);
 }
Exemplo n.º 8
0
 protected override void OnAccountInfo(LoginSession client, AccountLoginResult result, Account acc)
 {
     client.OnAccountInfo(result, acc);
 }
 protected abstract void OnAccountLoginResult(T client, AccountLoginResult result);
Exemplo n.º 10
0
 protected abstract void OnAccountInfo(T client, AccountLoginResult result, Account.Account acc);
Exemplo n.º 11
0
        static void HandleFailedLogin(IIPSocket conn, AccountLoginResult loginResult, string name)
        {
            // Get the error message
            switch (loginResult)
            {
                case AccountLoginResult.AccountInUse:
                    if (log.IsInfoEnabled)
                        log.InfoFormat("Login for account `{0}` failed: Account in use.", name);
                    conn.Disconnect(GameMessage.LoginAccountInUse);
                    break;

                case AccountLoginResult.InvalidName:
                    if (log.IsInfoEnabled)
                        log.InfoFormat("Login for account `{0}` failed: Invalid name.", name);
                    conn.Disconnect(GameMessage.LoginInvalidName);
                    break;

                case AccountLoginResult.InvalidPassword:
                    if (log.IsInfoEnabled)
                        log.InfoFormat("Login for account `{0}` failed: Incorrect password.", name);
                    conn.Disconnect(GameMessage.LoginInvalidPassword);
                    break;

                default:
                    // If the value is undefined, just say its an invalid name
                    const string errmsg = "Invalid AccountLoginResult value `{0}`.";
                    if (log.IsErrorEnabled)
                        log.ErrorFormat(errmsg, loginResult);
                    Debug.Fail(string.Format(errmsg, loginResult));
                    conn.Disconnect(GameMessage.LoginInvalidName);
                    break;
            }
        }
Exemplo n.º 12
0
 protected override void OnAccountInfo(GameSession client, AccountLoginResult result, Common.Account.Account acc)
 {
     client.OnAccountInfo(result, acc);
 }
Exemplo n.º 13
0
 protected override void OnAccountLoginResult(GameSession client, AccountLoginResult result)
 {
 }