Example #1
0
        // -------------------------------------------------------------------------------
        // RequestUserChangePassword
        // @Client
        // -------------------------------------------------------------------------------
        protected override bool RequestUserChangePassword(NetworkConnection conn, string name, string oldpassword, string newpassword)
        {
            if (!base.RequestUserChangePassword(conn, name, oldpassword, newpassword))
            {
                return(false);
            }

            ClientMessageRequestUserChangePassword message = new ClientMessageRequestUserChangePassword
            {
                username    = name,
                oldPassword = GenerateHash(name, oldpassword),
                newPassword = GenerateHash(name, newpassword)
            };

            // reset player prefs on password change
            PlayerPrefs.SetString(Constants.PlayerPrefsPassword, "");

            conn.Send(message);

            return(true);
        }
Example #2
0
        // -------------------------------------------------------------------------------
        // OnClientMessageRequestUserChangePassword
        // @Client -> @Server
        // -------------------------------------------------------------------------------
        void OnClientMessageRequestUserChangePassword(NetworkConnection conn, ClientMessageRequestUserChangePassword msg)
        {
            ServerMessageResponseUserChangePassword message = new ServerMessageResponseUserChangePassword
            {
                success          = true,
                text             = "",
                causesDisconnect = false
            };

            if (DatabaseManager.singleton.TryUserChangePassword(msg.username, msg.oldPassword, msg.newPassword))
            {
                message.text = systemText.userChangePasswordSuccess;
            }
            else
            {
                message.text    = systemText.userChangePasswordFailure;
                message.success = false;
            }

            conn.Send(message);
        }