codeigniter4 / shield

Authentication and Authorization for CodeIgniter 4
https://shield.codeigniter.com
MIT License
358 stars 128 forks source link

feat: add magic link force login config #1135

Closed warcooft closed 2 months ago

warcooft commented 3 months ago

Description

This feature provides config for developers so that the behavior when checking user sessions in the startLogin function can be easily controlled. So the user does not need to log out to assign a new user session.

We also set the default value in that configuration to false to preserve the previous behavior

Checklist:

kenjis commented 3 months ago

I submit a magicLink request using the incognito browser, then the magicLink sends an email to my my gmail in main browser. when opened it will cause a LogicException because in my main browser I am already logged in.

This could happen rarely. In this case, the CodeIgniter\Shield\Exceptions\LogicException should not happen. But I don't think you should be logged out automatically and logged in with the magic link. Because this scenario is not a normal use case. Showing the message with "you are already logged in as ..." is better?

kenjis commented 3 months ago

this case often occurs when development involves switching accounts with specific roles.

Shield does not have a feature to switch accounts. When you are logged in, if you navigate to login or login/magic-link, you will be redirected.

warcooft commented 3 months ago

I submit a magicLink request using the incognito browser, then the magicLink sends an email to my my gmail in main browser. when opened it will cause a LogicException because in my main browser I am already logged in.

This could happen rarely. In this case, the CodeIgniter\Shield\Exceptions\LogicException should not happen. But I don't think you should be logged out automatically and logged in with the magic link. Because this scenario is not a normal use case. Showing the message with "you are already logged in as ..." is better?

I agree instead of displaying exception/whoops page.