I’m using Entity Framework 4. I’m not really sure where the responsibility of setting a user’s password should be. I thought about on the Repository like SetPassword(User user, string password). But it doesn’t seem right.
The main problem is that it can’t just be a simple property setter since I also return the salt that’s generated.
You may want to create a module of some sort to handle password creation for the User class to call out to. This is more compliant with the Single Responsibility Principle (a class should have only 1 responsibility, sometimes read as “only 1 reason to change”).
Since your passwords should be salted and hashed before they are persisted, that’s definately out of the scope of what a User should be doing.
Then you could have a module separate of the User for authenticating the password using the same salt and hash method.