Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Password hashing etc in Service Layer or Repository?

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?

like image 763
Graham Conzett Avatar asked Aug 20 '09 16:08

Graham Conzett


1 Answers

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.

like image 133
Bill Karwin Avatar answered Oct 09 '22 01:10

Bill Karwin