I would recommend altering how you accomplish this. If you follow the flow below I think it will produce the results you're looking for:
- User arrives at URL (either by clicking link in email or typing it or whatever) but is not yet authenticated.
- Store the URL that the user is at in the session
- Redirect to the sign-in controller/action
- After authenticating the user look in the session for where you stored the arrival URL
- If present redirect to that URL (and clear stored URL out of the session) otherwise redirect to dashboard_url (it won't be present if someone navigates directly to the sign-in controller/action).