private void OnLogin()
    {
        if (string.IsNullOrEmpty(inputUsername.text))
        {
            return;
        }
        if (string.IsNullOrEmpty(inputPassword.text))
        {
            return;
        }
        var username = inputUsername.text;
        var password = inputPassword.text;

        AClientApis.OnLogin(username, MD5String.Hash32(password), EPartnerID.Test);
    }
    public static string generate(int intArg, string strArg, int iSessionArg)
    {
        DateTime dt = DateTime.Now;
        int      iMinute;

/*
 *              if (iSessionArg == 0)
 *              {
 *                      iMinute = (dt - new DateTime(1970, 1, 1)).Minutes + iSessionArg;
 *              }
 *              else
 *              {
 */
        iMinute = iSessionArg;

/*
 *              }
 */
        string sResult = MD5String.Hash32(intArg + strArg + iMinute + session_auth_key);

        return(sResult);
    }
        private void GameHandler_Login(IResponer responer, PktLoginRequest vo)
        {
            var res = new PktLoginResult();

            switch ((EPartnerID)vo.ePartnerID)
            {
            case EPartnerID.Test:
                if (vo.password == MD5String.Hash32(vo.username))
                {
                    res.bSuccess   = true;
                    res.ePartnerID = vo.ePartnerID;
                    res.unionid    = MD5String.Hash32(vo.password + vo.username);
                }
                break;

            default:
                break;
            }
            if (res.bSuccess)
            {
                APlayerManager.Instance.OnAddPlayer(res.unionid, (EPartnerID)vo.ePartnerID, responer);
            }
            responer.Response(res);
        }
Example #4
0
        private void Handler_Login(IResponer arg1, PktLoginRequest arg2)
        {
            var res = new PktLoginResult();

            switch (arg2.ePartnerID)
            {
            case PktLoginRequest.EPartnerID.Test:
                if (arg2.password == MD5String.Hash32(arg2.username))
                {
                    res.bSuccess   = true;
                    res.ePartnerID = arg2.ePartnerID;
                    res.uid        = MD5String.Hash32(arg2.password + arg2.username);
                }
                break;

            default:
                break;
            }
            if (res.bSuccess)
            {
                res.token = LibServer.Managers.ATokenManager.Instance.AddToken(res.ePartnerID, res.uid);
            }
            arg1.Response(res);
        }
        public HttpResponseMessage Register(string username, string password, string mail)
        {
            if (!mail.Contains("@") || !mail.Contains(".") || mail.IndexOf("@") > mail.IndexOf("."))
            {
                return(ResultToJson.GetErrorJsonResponse("Invalid mail address."));
            }

            if (username.Length < 4)
            {
                return(ResultToJson.GetErrorJsonResponse("Too short username."));
            }
            if (username.Length > 16)
            {
                return(ResultToJson.GetErrorJsonResponse("Too long username."));
            }

            var res = ADatabaseConfigsManager.userDB.FindOneData(ADatabaseConfigsManager.tUserData, ADBAccessor.filter_eq(InfoNameDefs.Username, username));

            if (res != null)
            {
                return(ResultToJson.GetErrorJsonResponse("Username registered."));
            }
            var token = AWebServerUtils.GetEncryptCode(12);

            ADatabaseConfigsManager.userDB.UpdateOneData(ADatabaseConfigsManager.tUserData, ADBAccessor.filter_eq(InfoNameDefs.Username, username)
                                                         , ADBAccessor.updates_build(
                                                             ADBAccessor.update(InfoNameDefs.UserToken, token)
                                                             , ADBAccessor.update(InfoNameDefs.Username, username)
                                                             , ADBAccessor.update(InfoNameDefs.UserMail, mail)
                                                             , ADBAccessor.update(InfoNameDefs.UserPassword, MD5String.Hash32(password))
                                                             )
                                                         , true);

            ATokenManager.Instance.OnSetToken(username, token);
            return(ResultToJson.GetJsonResponse(InfoNameDefs.Username, username, InfoNameDefs.UserToken, token));
        }
        public HttpResponseMessage Login(string username, string password)
        {
            var res = ADatabaseConfigsManager.userDB.FindOneData(ADatabaseConfigsManager.tUserData, ADBAccessor.filter_eq(InfoNameDefs.Username, username) & ADBAccessor.filter_eq(InfoNameDefs.UserPassword, MD5String.Hash32(password)));

            if (res == null)
            {
                return(ResultToJson.GetErrorJsonResponse("Username and password mismatch."));
            }
            var token = "";

            if (res.Contains(InfoNameDefs.UserToken))
            {
                token = res[InfoNameDefs.UserToken].ToString();
            }
            else
            {
                token = AWebServerUtils.GetEncryptCode(12);
                ADatabaseConfigsManager.userDB.UpdateOneData(ADatabaseConfigsManager.tUserData, ADBAccessor.filter_eq(InfoNameDefs.Username, username), ADBAccessor.update(InfoNameDefs.UserToken, token));
            }
            return(ResultToJson.GetJsonResponse(InfoNameDefs.UserToken, res[InfoNameDefs.UserToken].ToString()));
        }
Example #7
0
        public void accountregister(string username, string password, string mail)
        {
            if (!mail.Contains("@") || !mail.Contains(".") || mail.IndexOf("@") > mail.IndexOf("."))
            {
                SendError(ErrorDefs.InvalidEmailAddress);
                return;
            }

            var result = dbaccount.FindOneData(tUserData, ADBAccessor.filter_eq(InfoNameDefs.Username, username), null);

            if (result != null)
            {
                SendError(ErrorDefs.DuplicateUsername);
            }
            else
            {
                var fdresult = dbaccount.UpdateOneData(tUserData, ADBAccessor.filter_eq(InfoNameDefs.Username, username)
                                                       , ADBAccessor.updates_build(
                                                           ADBAccessor.update(InfoNameDefs.UserPassword, MD5String.Hash32(password))
                                                           , ADBAccessor.update(InfoNameDefs.UserMail, mail)
                                                           , ADBAccessor.update(InfoNameDefs.Username, username)
                                                           ), true);
                if (fdresult)
                {
                    SendError(Context.Response, "username", username);
                }
                else
                {
                    SendDBError();
                }
            }
        }
Example #8
0
        public void accountlogin(string username, string password)
        {
            if (username == "fs" && password == "111")
            {
                if (!dUserTokens.ContainsKey(username))
                {
                    dUserTokens.Add(username, "1");
                }
                SendError("token", "1");
                return;
            }
            var result = dbaccount.FindOneData(tUserData
                                               , ADBAccessor.filter_eq(InfoNameDefs.Username, username)
                                               & ADBAccessor.filter_eq(InfoNameDefs.UserPassword, MD5String.Hash32(password))
                                               , null);

            if (result != null)
            {
                if (result.Contains(InfoNameDefs.Username))
                {
                    var token = "";
                    if (result.Contains(InfoNameDefs.UserToken))
                    {
                        token = result[InfoNameDefs.UserToken].AsString;
                    }
                    else
                    {
                        token = AWebServerUtils.GetEncryptCode();
                        var updateRes = dbaccount.UpdateOneData(tUserData, ADBAccessor.filter_eq(InfoNameDefs.Username, username)
                                                                , ADBAccessor.updates_build(ADBAccessor.update(InfoNameDefs.UserToken, token)), false);
                        if (!updateRes)
                        {
                            SendDBError();
                            return;
                        }
                    }
                    if (!dUserTokens.ContainsKey(username))
                    {
                        dUserTokens.Add(username, token);
                    }
                    SendError(InfoNameDefs.Username, username, InfoNameDefs.UserToken, dUserTokens[username]);
                }
                else
                {
                    SendError(ErrorDefs.UsernamePasswordMismatch);
                }
            }
            else
            {
                SendError(ErrorDefs.UsernamePasswordMismatch);
            }
        }
 private void OnLogin(string[] sCmds)
 {
     AClientApis.OnLogin(sCmds[1], MD5String.Hash32(sCmds[2]), EPartnerID.Test);
 }