amnah / yii2-user

Yii2 user authentication module
MIT License
253 stars 104 forks source link

Best setup for frontend and backend user login #128

Closed cicsolutions closed 8 years ago

cicsolutions commented 8 years ago

Hello, I'm curious what you would recommend as the best way to set up separated login views for the backend and frontend apps. I'm not sure if the controller logic needs to be overridden or not, but what I'd like to do is:

1) have a separate view file used for the login view - as this will allow me to remove links such as the "register" link on the backend login view.

2) have different redirect urls after login. My site is set up so that domain.com is my frontend app and domain.com/admin is my backend app. Therefore, I'd like frontend users to get redirected to domain.com after logging in, whereas backend users would get redirected to domain.com/admin after logging in.

I'm already overriding Amnah User controllers, and placing the DefaultController in the frontend and the AdminController in the backend. So I guess I'm not far from just duplicating the login actions from the DefaultController into the AdminController, but I'm wondering if there is a simpler/cleaner way to accomplish my objectives.

I welcome any input or suggestions you can offer. Please let me know if I can provide any further information about my existing setup that may help. Thanks so much!

amnah commented 8 years ago

I would just duplicate the code and modify it as needed. 1) it keeps it in the AdminController space, and 2) Admin logins have slightly different logic (eg, different login redirect url and you have to also check that they're an admin user)

cicsolutions commented 8 years ago

Makes great sense! Thank you!