As a matter of best practice in MVC, where should the logic go that deals with things such as password hashing/salting or data formatting before it gets sent to the database? I've read that the repository should only be used for logic that deals with data access. Is this something that belongs in a service layer? The controller? Does it even matter?
+5
A:
I'd be inclined to put the hashing in the repository layer, if only for the practical reason that you know if there's more than one service class that needs to store passwords, you'll have some assurance they don't do the hashing differently. Basically, follow the DRY principle.
Bill Karwin
2009-08-20 16:59:18
That makes sense, thank you.
Graham
2009-08-20 18:37:48
+1
A:
I think it depends on how you look at it. I'd be inclined to think of password hashing as something as necessary and therefore akin to, for example, escaping input before it goes to the database. In that case it would belong in the repository
David Archer
2009-08-20 17:09:16
Another vote for repository, I think that's where I'll stick it. Thanks for your input.
Graham
2009-08-20 18:38:54