Esempio n. 1
0
        // -------------------------------------------------------------------------------
        // OnClientMessageRequestUserChangePassword
        // @Client -> @Server
        // -------------------------------------------------------------------------------
        /// <summary>
        /// Event <c>OnClientMessageRequestUserChangePassword</c>.
        /// Triggered when the server receives a user change password request.
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="msg"></param>
        void OnClientMessageRequestUserChangePassword(NetworkConnection conn, ClientMessageRequestUserChangePassword msg)
        {
            ServerMessageResponseUserChangePassword message = new ServerMessageResponseUserChangePassword
            {
                success          = true,
                text             = "",
                causesDisconnect = false
            };

            if (!GetIsUserLoggedIn(msg.username) && DatabaseManager.singleton.TryUserChangePassword(msg.username, msg.oldPassword, msg.newPassword))
            {
                message.text = systemText.userChangePasswordSuccess;

                debug.LogFormat(this.name, nameof(OnClientMessageRequestUserChangePassword), conn.Id(), "Success");                 //DEBUG
            }
            else
            {
                message.text    = systemText.userChangePasswordFailure;
                message.success = false;

                debug.LogFormat(this.name, nameof(OnClientMessageRequestUserChangePassword), conn.Id(), "DENIED");                 //DEBUG
            }

            conn.Send(message);
        }
Esempio n. 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);
        }
Esempio n. 3
0
        // -------------------------------------------------------------------------------
        // RequestUserChangePassword
        // @Client
        // -------------------------------------------------------------------------------
        protected override bool RequestUserChangePassword(NetworkConnection conn, string userName, string oldpassword, string newpassword)
        {
            if (!base.RequestUserChangePassword(conn, userName, oldpassword, newpassword))
            {
                return(false);
            }

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

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

            conn.Send(message);

            return(true);
        }