Where to place the login/authentication related actions in MVC

Posted by rogeriopvl on Stack Overflow See other posts from Stack Overflow or by rogeriopvl
Published on 2010-03-16T22:58:42Z Indexed on 2010/03/16 23:01 UTC
Read the original article Hit count: 199

Filed under:
|

I've searched around and found that when implementing an authentication module in MVC architecture some people opt to place the login related actions in the User controller while others place it in a controller dedicated to authentication only.

In pseudo-java-like code:

class UserController extends Controller {

    public login() {
        //...
    }
}

Accessed with http://mydomain.com/user/login.

vs.

class AuthController extends Controller {

    public login() {
        //...
    }
}

Accessed with http://mydomain.com/auth/login.

I would like to know which approach is better, and why. That is, if there's really any difference at all.

Thanks in advance.

© Stack Overflow or respective owner

Related posts about mvc

Related posts about best-practices