Example #1
0
        public void OnTryRegister(SvManager svManager, AuthData authData, ConnectData connectData)
        {
            if (ValidateUser(svManager, authData))
            {
                if (svManager.TryGetUserData(authData.accountID, out User playerData))
                {
                    if (playerData.BanInfo.IsBanned)
                    {
                        svManager.RegisterFail(authData.connection, $"Account banned: {playerData.BanInfo.Reason}");
                        return;
                    }

                    if (!svManager.settings.auth.steam && playerData.PasswordHash != connectData.passwordHash)
                    {
                        svManager.RegisterFail(authData.connection, $"Invalid credentials");
                        return;
                    }
                }

                if (!connectData.username.ValidCredential())
                {
                    svManager.RegisterFail(authData.connection, $"Name cannot be registered (min: {Util.minCredential}, max: {Util.maxCredential})");
                    return;
                }

                svManager.AddNewPlayer(authData, connectData);
            }
        }
Example #2
0
        public void OnTryRegister(SvManager svManager, ConnectionData connectionData)
        {
            if (ValidateUser(svManager, connectionData))
            {
                if (svManager.TryGetUserData(connectionData.username, out var playerData))
                {
                    if (playerData.PasswordHash != connectionData.passwordHash)
                    {
                        svManager.RegisterFail(connectionData.connection, "Invalid credentials");
                        return;
                    }

                    if (!Utility.tryRegister.Limit(connectionData.username))
                    {
                        svManager.RegisterFail(connectionData.connection, $"Character {connectionData.username} Exists - Sure you want to Register?");
                        return;
                    }
                }

                if (!connectionData.username.ValidCredential())
                {
                    svManager.RegisterFail(connectionData.connection, $"Name cannot be registered (min: {Util.minCredential}, max: {Util.maxCredential})");
                    return;
                }

                svManager.AddNewPlayer(connectionData, playerData?.Persistent);
            }
        }
Example #3
0
        public void OnTryLogin(SvManager svManager, AuthData authData, ConnectData connectData)
        {
            if (ValidateUser(svManager, authData))
            {
                if (!svManager.TryGetUserData(authData.accountID, out User playerData))
                {
                    svManager.RegisterFail(authData.connection, "Account not found - Please Register");
                    return;
                }

                if (playerData.BanInfo.IsBanned)
                {
                    svManager.RegisterFail(authData.connection, $"Account banned: {playerData.BanInfo.Reason}");
                    return;
                }

                if (!svManager.settings.auth.steam && playerData.PasswordHash != connectData.passwordHash)
                {
                    svManager.RegisterFail(authData.connection, $"Invalid credentials");
                    return;
                }

                svManager.LoadSavedPlayer(playerData, authData, connectData);
            }
        }
Example #4
0
        public void OnTryRegister(SvManager svManager, ConnectionData connectData)
        {
            if (ValidateUser(svManager, connectData))
            {
                if (svManager.TryGetUserData(connectData.username, out User playerData))
                {
                    if (playerData.PasswordHash != connectData.passwordHash)
                    {
                        svManager.RegisterFail(connectData.connection, "Invalid credentials");
                        return;
                    }
                }

                if (!connectData.username.ValidCredential())
                {
                    svManager.RegisterFail(connectData.connection, $"Name cannot be registered (min: {Util.minCredential}, max: {Util.maxCredential})");
                    return;
                }

                if (!connectData.username.ValidCredential())
                {
                    svManager.RegisterFail(connectData.connection, $"Name cannot be registered (min: {Util.minCredential}, max: {Util.maxCredential})");
                    return;
                }
                // -- BPE EXTEND
                if (Core.Instance.Settings.General.LimitNames && !Regex.IsMatch(connectData.username, @"^[a-zA-Z0-9_]+$"))
                {
                    svManager.RegisterFail(connectData.connection, $"Your Username can only contain letters: A-Z a-z 0-9 _ -");
                    return;
                }
                // BPE EXTEND --
                svManager.AddNewPlayer(connectData);
            }
        }
Example #5
0
        public void OnTryRegister(SvManager svManager, ConnectionData connectionData)
        {
            if (ValidateUser(svManager, connectionData))
            {
                if (svManager.TryGetUserData(connectionData.username, out User playerData))
                {
                    if (Core.Instance.Settings.General.DisableAccountOverwrite)
                    {
                        svManager.RegisterFail(connectionData.connection, "This Name has already been registerd and this Server has disabled overwriting Accounts!");
                        return;
                    }
                    if (playerData.PasswordHash != connectionData.passwordHash)
                    {
                        svManager.RegisterFail(connectionData.connection, "Invalid credentials");
                        return;
                    }
                }

                if (!connectionData.username.ValidCredential())
                {
                    svManager.RegisterFail(connectionData.connection, $"Name cannot be registered (min: {Util.minCredential}, max: {Util.maxCredential})");
                    return;
                }
                // -- BPE EXTEND
                if (Core.Instance.Settings.General.LimitNames && !Regex.IsMatch(connectionData.username, @"^[a-zA-Z0-9_-]+$"))
                {
                    svManager.RegisterFail(connectionData.connection, $"Your Username can only contain letters: A-Z a-z 0-9 _ -");
                    return;
                }
                // BPE EXTEND --
                svManager.AddNewPlayer(connectionData, playerData?.Persistent);
            }
        }
Example #6
0
 public bool OnTryRegister(SvManager svManager, ConnectionData connectionData)
 {
     if (Core.Instance.Settings.General.LimitNames && !Regex.IsMatch(connectionData.username, @"^[a-zA-Z0-9_-]+$"))
     {
         svManager.RegisterFail(connectionData.connection, $"Your username can only contain the following characters: A-Z a-z 0-9 _ -");
         return(false);
     }
     if (svManager.TryGetUserData(connectionData.username, out var user) && Core.Instance.Settings.General.DisableAccountOverwrite)
     {
         svManager.RegisterFail(connectionData.connection, "This name has already been registered and this server has disabled overwriting accounts!");
         return(false);
     }
     return(true);
 }
Example #7
0
        private bool ValidateUser(SvManager svManager, ConnectionData connectionData)
        {
            if (!svManager.HandleWhitelist(connectionData.username))
            {
                svManager.RegisterFail(connectionData.connection, "Account not whitelisted");
                return(false);
            }

            // Don't allow multi-boxing, WebAPI doesn't prevent this
            if (EntityCollections.Accounts.ContainsKey(connectionData.username))
            {
                svManager.RegisterFail(connectionData.connection, "Account still logged in");
                return(false);
            }

            return(true);
        }
Example #8
0
        public void OnTryLogin(SvManager svManager, ConnectionData connectionData)
        {
            if (ValidateUser(svManager, connectionData))
            {
                if (!svManager.TryGetUserData(connectionData.username, out var playerData))
                {
                    svManager.RegisterFail(connectionData.connection, "Account not found - Please Register");
                    return;
                }

                if (playerData.PasswordHash != connectionData.passwordHash)
                {
                    svManager.RegisterFail(connectionData.connection, "Invalid credentials");
                    return;
                }

                svManager.LoadSavedPlayer(playerData, connectionData);
            }
        }
Example #9
0
        private bool ValidateUser(SvManager svManager, AuthData authData)
        {
            if (!svManager.HandleWhitelist(authData.accountID))
            {
                svManager.RegisterFail(authData.connection, "Account not whitelisted");
                return(false);
            }

            // Don't allow multi-boxing, WebAPI doesn't prevent this
            foreach (ShPlayer p in EntityCollections.Humans)
            {
                if (p.accountID == authData.accountID)
                {
                    svManager.RegisterFail(authData.connection, "Account still logged in");
                    return(false);
                }
            }

            return(true);
        }