JSON-RPC: fixes, refactoring and cosmetics in Profiles.LoadProfile

Right now Profiles.LoadProfile only works if neither the master profile nor the profile to be loaded have a password set.

The third commit fixes login with passwords (same reason as explained in #5455).

The fourth commit fixes login into a password-less profile in the case where the master profile has a password set. We accidentally always checked the lock mode of the master profile instead of checking the lock mode of the profile we are trying to load / log into.

While hunting down these bugs I realized that the code doesn't really follow our coding guidelines. The first commit replaces some tabs with two spaces. The second commit cleans the code a bit up and makes it simpler where it's unnecessarily complicated.