示例#1
0
        public static MemberAuthenticationResultView Deserialize(Stream bytes)
        {
            int mask = Int32Proxy.Deserialize(bytes);
            var view = new MemberAuthenticationResultView();

            if ((mask & 1) != 0)
            {
                view.AuthToken = StringProxy.Deserialize(bytes);
            }

            view.IsAccountComplete = BooleanProxy.Deserialize(bytes);

            if ((mask & 2) != 0)
            {
                view.LuckyDraw = LuckyDrawUnityViewProxy.Deserialize(bytes);
            }

            view.MemberAuthenticationResult = EnumProxy <MemberAuthenticationResult> .Deserialize(bytes);

            if ((mask & 4) != 0)
            {
                view.MemberView = MemberViewProxy.Deserialize(bytes);
            }
            if ((mask & 8) != 0)
            {
                view.PlayerStatisticsView = PlayerStatisticsViewProxy.Deserialize(bytes);
            }

            view.ServerTime = DateTimeProxy.Deserialize(bytes);
            return(view);
        }
示例#2
0
        public static void Serialize(Stream stream, MemberAuthenticationResultView instance)
        {
            int mask = 0;

            using (var bytes = new MemoryStream())
            {
                if (instance.AuthToken != null)
                {
                    StringProxy.Serialize(bytes, instance.AuthToken);
                }
                else
                {
                    mask |= 1;
                }

                BooleanProxy.Serialize(bytes, instance.IsAccountComplete);

                if (instance.LuckyDraw != null)
                {
                    LuckyDrawUnityViewProxy.Serialize(bytes, instance.LuckyDraw);
                }
                else
                {
                    mask |= 2;
                }

                EnumProxy <MemberAuthenticationResult> .Serialize(bytes, instance.MemberAuthenticationResult);

                if (instance.MemberView != null)
                {
                    MemberViewProxy.Serialize(bytes, instance.MemberView);
                }
                else
                {
                    mask |= 4;
                }
                if (instance.PlayerStatisticsView != null)
                {
                    PlayerStatisticsViewProxy.Serialize(bytes, instance.PlayerStatisticsView);
                }
                else
                {
                    mask |= 8;
                }

                DateTimeProxy.Serialize(bytes, instance.ServerTime);
                Int32Proxy.Serialize(stream, ~mask);
                bytes.WriteTo(stream);
            }
        }
    public IEnumerator StartLoginMemberEmail(string emailAddress, string password)
    {
        if (string.IsNullOrEmpty(emailAddress) || string.IsNullOrEmpty(password))
        {
            ShowLoginErrorPopup(LocalizedStrings.Error, "Your login credentials are not correct. Please try to login again.");
            yield break;
        }
        _progress.Text     = "Authenticating Account";
        _progress.Progress = 0.1f;
        PopupSystem.Show(_progress);
        MemberAuthenticationResultView authenticationView = null;

        if (ApplicationDataManager.Channel == ChannelType.Steam)
        {
            yield return(AuthenticationWebServiceClient.LinkSteamMember(emailAddress, password, PlayerDataManager.SteamId, SystemInfo.deviceUniqueIdentifier, delegate(MemberAuthenticationResultView ev)
            {
                authenticationView = ev;
                PlayerPrefs.SetString("CurrentSteamUser", PlayerDataManager.SteamId);
                PlayerPrefs.Save();
            }, delegate(Exception ex)
            {
            }));
        }
        else
        {
            yield return(AuthenticationWebServiceClient.LoginMemberEmail(emailAddress, password, ApplicationDataManager.Channel, SystemInfo.deviceUniqueIdentifier, delegate(MemberAuthenticationResultView ev)
            {
                authenticationView = ev;
            }, delegate(Exception ex)
            {
            }));
        }
        if (authenticationView == null)
        {
            ShowLoginErrorPopup(LocalizedStrings.Error, "The login could not be processed. Please check your internet connection and try again.");
            yield break;
        }
        yield return(UnityRuntime.StartRoutine(CompleteAuthentication(authenticationView, false)));

        yield break;
    }
    public IEnumerator StartLoginMemberSteam(bool directSteamLogin)
    {
        if (directSteamLogin)
        {
            _progress.Text     = "Authenticating with Steam";
            _progress.Progress = 0.05f;
            PopupSystem.Show(_progress);
            m_GetAuthSessionTicketResponse = Callback <GetAuthSessionTicketResponse_t> .Create(new Callback <GetAuthSessionTicketResponse_t> .DispatchDelegate(OnGetAuthSessionTicketResponse));

            byte[]      ticket = new byte[1024];
            uint        pcbTicket;
            HAuthTicket authTicket = SteamUser.GetAuthSessionTicket(ticket, 1024, out pcbTicket);
            int         num        = (int)pcbTicket;
            string      authToken  = num.ToString();
            string      machineId  = SystemInfo.deviceUniqueIdentifier;
            MemberAuthenticationResultView authenticationView = null;
            _progress.Text     = "Authenticating with UberStrike";
            _progress.Progress = 0.1f;
            yield return(AuthenticationWebServiceClient.LoginSteam(PlayerDataManager.SteamId, authToken, machineId, delegate(MemberAuthenticationResultView result)
            {
                authenticationView = result;
                PlayerPrefs.SetString("CurrentSteamUser", PlayerDataManager.SteamId);
                PlayerPrefs.Save();
            }, delegate(Exception error)
            {
                Debug.LogError("Account authentication error: " + error);
                ShowLoginErrorPopup(LocalizedStrings.Error, "There was an error logging you in. Please try again or contact us at http://support.cmune.com");
            }));

            yield return(UnityRuntime.StartRoutine(CompleteAuthentication(authenticationView, false)));
        }
        else
        {
            PopupSystem.ClearAll();
            yield return(PanelManager.Instance.OpenPanel(PanelType.Login));
        }
        yield break;
    }
        public override MemberAuthenticationResultView OnLoginSteam(string steamId, string authToken, string machineId)
        {
            // Figure out if the account has been linked.
            var linked = true;
            // Figure out if the account existed. true -> existed otherwise false.
            var incomplete = false;

            // Load the user from the database using its steamId.
            var member = Context.Users.Db.LoadMember(steamId);

            if (member == null)
            {
                Log.Info($"Member entry {steamId} does not exists, creating new entry");

                // Create a new member if its not in the db.
                incomplete = true;
                member     = Context.Users.NewMember();

                // Link the Steam ID to the CMID.
                linked = Context.Users.Db.Link(steamId, member);
            }
#if DEBUG
            else
            {
                var memoryMember = Context.Users.GetMember(member.PublicProfile.Cmid);
                if (memoryMember != null)
                {
                    member = Context.Users.NewMember();
                    Log.Info($"Faking member {memoryMember.PublicProfile.Cmid} with {member.PublicProfile.Cmid}");
                }
            }
#endif

            var result = MemberAuthenticationResult.Ok;
            if (!linked)
            {
                result = MemberAuthenticationResult.InvalidEsns;
            }

            // Use the PublicProfile.EmailAddrsessStatus to figure out if its an incomplete account,
            // because why not.
            if (member.PublicProfile.EmailAddressStatus == EmailAddressStatus.Unverified)
            {
                incomplete = true;
            }

            var newAuthToken = Context.Users.LogInUser(member);
            var view         = new MemberAuthenticationResultView
            {
                MemberAuthenticationResult = result,
                AuthToken         = newAuthToken,
                IsAccountComplete = !incomplete,
                ServerTime        = DateTime.Now,

                MemberView           = member,
                PlayerStatisticsView = new PlayerStatisticsView
                {
                    Cmid             = member.PublicProfile.Cmid,
                    PersonalRecord   = new PlayerPersonalRecordStatisticsView(),
                    WeaponStatistics = new PlayerWeaponStatisticsView()
                },
            };

            Log.Info($"Logging in member {steamId}:{newAuthToken}");

            return(view);
        }
示例#6
0
        public byte[] LoginSteam(byte[] data)
        {
            var inputStream = new MemoryStream(data);

            var steamId   = StringProxy.Deserialize(inputStream);
            var authToken = StringProxy.Deserialize(inputStream);
            var machineId = StringProxy.Deserialize(inputStream);

            var outputStream = new MemoryStream();

            if (userData.ContainsKey(steamId) && userData[steamId] != null)
            {
                var instance = new MemberAuthenticationResultView {
                    MemberAuthenticationResult = MemberAuthenticationResult.Ok,
                    MemberView           = userData[steamId],
                    PlayerStatisticsView = playerStatistics[steamId],
                    ServerTime           = DateTime.Now,
                    IsAccountComplete    = true,
                    AuthToken            = Convert.ToBase64String(Encoding.UTF8.GetBytes(steamId))
                };

                MemberAuthenticationResultViewProxy.Serialize(outputStream, instance);
            }
            else
            {
                var r    = new Random((int)DateTime.Now.Ticks);
                var Cmid = r.Next(1000000, 9999999);

                var newMemberView = new MemberView {
                    PublicProfile = new PublicProfileView {
                        Cmid               = Cmid,
                        Name               = "Player Name",
                        IsChatDisabled     = false,
                        AccessLevel        = MemberAccessLevel.Default,
                        GroupTag           = "",
                        LastLoginDate      = DateTime.Now,
                        EmailAddressStatus = EmailAddressStatus.Verified,
                        FacebookId         = "-1"
                    },
                    MemberWallet = new MemberWalletView {
                        Cmid    = Cmid,
                        Credits = 2000,
                        Points  = 2000
                    }
                };

                var newPlayerStatisticsView = new PlayerStatisticsView {
                    Cmid             = Cmid,
                    PersonalRecord   = new PlayerPersonalRecordStatisticsView(),
                    WeaponStatistics = new PlayerWeaponStatisticsView()
                };

                var instance = new MemberAuthenticationResultView {
                    MemberAuthenticationResult = MemberAuthenticationResult.Ok,
                    MemberView           = newMemberView,
                    PlayerStatisticsView = newPlayerStatisticsView,
                    ServerTime           = DateTime.Now,
                    IsAccountComplete    = true,
                    AuthToken            = Convert.ToBase64String(Encoding.UTF8.GetBytes(steamId))
                };

                userData[steamId]         = newMemberView;
                playerStatistics[steamId] = newPlayerStatisticsView;

                MemberAuthenticationResultViewProxy.Serialize(outputStream, instance);

                UpdatePlayerData();
            }

            return(outputStream.ToArray());
        }
    private IEnumerator CompleteAuthentication(MemberAuthenticationResultView authView, bool isRegistrationLogin = false)
    {
        if (authView == null)
        {
            Debug.LogError("Account authentication error: MemberAuthenticationResultView was null, isRegistrationLogin: "******"There was an error logging you in. Please try again or contact us at http://support.cmune.com");
            yield break;
        }
        if (authView.MemberAuthenticationResult == MemberAuthenticationResult.IsBanned || authView.MemberAuthenticationResult == MemberAuthenticationResult.IsIpBanned)
        {
            ApplicationDataManager.LockApplication(LocalizedStrings.YourAccountHasBeenBanned);
            yield break;
        }
        if (authView.MemberAuthenticationResult == MemberAuthenticationResult.InvalidEsns)
        {
            Debug.Log("Result: " + authView.MemberAuthenticationResult);
            ShowLoginErrorPopup(LocalizedStrings.Error, "Sorry, this account is linked already.");
            yield break;
        }
        if (authView.MemberAuthenticationResult != MemberAuthenticationResult.Ok)
        {
            Debug.Log("Result: " + authView.MemberAuthenticationResult);
            ShowLoginErrorPopup(LocalizedStrings.Error, "Your login credentials are not correct. Please try to login again.");
            yield break;
        }
        Singleton <PlayerDataManager> .Instance.SetLocalPlayerMemberView(authView.MemberView);

        PlayerDataManager.AuthToken = authView.AuthToken;
        if (!PlayerDataManager.IsTestBuild)
        {
            PlayerDataManager.MagicHash = UberDaemon.Instance.GetMagicHash(authView.AuthToken);
            Debug.Log("Magic Hash:" + PlayerDataManager.MagicHash);
        }
        ApplicationDataManager.ServerDateTime = authView.ServerTime;
        global::EventHandler.Global.Fire(new GlobalEvents.Login(authView.MemberView.PublicProfile.AccessLevel));
        _progress.Text     = LocalizedStrings.LoadingFriendsList;
        _progress.Progress = 0.2f;
        yield return(UnityRuntime.StartRoutine(Singleton <CommsManager> .Instance.GetContactsByGroups()));

        _progress.Text     = LocalizedStrings.LoadingCharacterData;
        _progress.Progress = 0.3f;
        yield return(ApplicationWebServiceClient.GetConfigurationData("4.7.1", delegate(ApplicationConfigurationView appConfigView)
        {
            XpPointsUtil.Config = appConfigView;
        }, delegate(Exception ex)
        {
            ApplicationDataManager.LockApplication(LocalizedStrings.ErrorLoadingData);
        }));

        Singleton <PlayerDataManager> .Instance.SetPlayerStatisticsView(authView.PlayerStatisticsView);

        _progress.Text     = LocalizedStrings.LoadingMapData;
        _progress.Progress = 0.5f;
        bool mapsLoadedSuccessfully = false;

        yield return(ApplicationWebServiceClient.GetMaps("4.7.1", DefinitionType.StandardDefinition, delegate(List <MapView> callback)
        {
            mapsLoadedSuccessfully = Singleton <MapManager> .Instance.InitializeMapsToLoad(callback);
        }, delegate(Exception ex)
        {
            ApplicationDataManager.LockApplication(LocalizedStrings.ErrorLoadingMaps);
        }));

        if (!mapsLoadedSuccessfully)
        {
            ShowLoginErrorPopup(LocalizedStrings.Error, LocalizedStrings.ErrorLoadingMapsSupport);
            PopupSystem.HideMessage(_progress);
            yield break;
        }
        _progress.Progress = 0.6f;
        _progress.Text     = LocalizedStrings.LoadingWeaponAndGear;
        yield return(UnityRuntime.StartRoutine(Singleton <ItemManager> .Instance.StartGetShop()));

        if (!Singleton <ItemManager> .Instance.ValidateItemMall())
        {
            PopupSystem.HideMessage(_progress);
            yield break;
        }
        _progress.Progress = 0.7f;
        _progress.Text     = LocalizedStrings.LoadingPlayerInventory;
        yield return(UnityRuntime.StartRoutine(Singleton <ItemManager> .Instance.StartGetInventory(false)));

        _progress.Progress = 0.8f;
        _progress.Text     = LocalizedStrings.GettingPlayerLoadout;
        yield return(UnityRuntime.StartRoutine(Singleton <PlayerDataManager> .Instance.StartGetLoadout()));

        if (!Singleton <LoadoutManager> .Instance.ValidateLoadout())
        {
            ShowLoginErrorPopup(LocalizedStrings.ErrorGettingPlayerLoadout, LocalizedStrings.ErrorGettingPlayerLoadoutSupport);
            yield break;
        }
        _progress.Progress = 0.85f;
        _progress.Text     = LocalizedStrings.LoadingPlayerStatistics;
        yield return(UnityRuntime.StartRoutine(Singleton <PlayerDataManager> .Instance.StartGetMember()));

        if (!Singleton <PlayerDataManager> .Instance.ValidateMemberData())
        {
            ShowLoginErrorPopup(LocalizedStrings.ErrorGettingPlayerStatistics, LocalizedStrings.ErrorPlayerStatisticsSupport);
            yield break;
        }
        _progress.Progress = 0.9f;
        _progress.Text     = LocalizedStrings.LoadingClanData;
        yield return(ClanWebServiceClient.GetMyClanId(PlayerDataManager.AuthToken, delegate(int id)
        {
            PlayerDataManager.ClanID = id;
        }, delegate(Exception ex)
        {
        }));

        if (PlayerDataManager.ClanID > 0)
        {
            yield return(ClanWebServiceClient.GetOwnClan(PlayerDataManager.AuthToken, PlayerDataManager.ClanID, delegate(ClanView ev)
            {
                Singleton <ClanDataManager> .Instance.SetClanData(ev);
            }, delegate(Exception ex)
            {
            }));
        }
        GameState.Current.Avatar.SetDecorator(AvatarBuilder.CreateLocalAvatar());
        GameState.Current.Avatar.UpdateAllWeapons();
        yield return(new WaitForEndOfFrame());

        Singleton <InboxManager> .Instance.Initialize();

        yield return(new WaitForEndOfFrame());

        Singleton <BundleManager> .Instance.Initialize();

        yield return(new WaitForEndOfFrame());

        PopupSystem.HideMessage(_progress);
        if (!authView.IsAccountComplete)
        {
            PanelManager.Instance.OpenPanel(PanelType.CompleteAccount);
        }
        else
        {
            MenuPageManager.Instance.LoadPage(PageType.Home, false);
            IsAuthComplete = true;
        }
        Debug.LogWarning(string.Format("AuthToken:{0}, MagicHash:{1}", PlayerDataManager.AuthToken, PlayerDataManager.MagicHash));
        yield break;
    }