Redirect to referral source just after login or signup

Hi, I have setup discourse for my community and here is one use case I have, please help me how can I do this:

  1. User land to my main website ex (MyStaticWebsite.com/xyz)
  2. I have put a hyperlink on my main website called Login/Signup and link it to http://discourse.MyStaticWebsite.com/login
  3. After authentication is there any way I can identify the referral at this point and can redirect user to the referring url (MyStaticWebsite.com/xyz) ??

This is not possible at the moment without a custom theme component. Nervous about adding a feature like this cause it can be used for abuse if it is provided by the end user.