redirect after login/signup

Hi, Thank you for your help, I tried it but it didn’t work.
I will explain what i’m trying to do, maybe there is a better way of implementing it.

I have a button that when you press on it - if you are logged in - you are directed to a site member page, but if you are not logged in, I open a light box that explains the user that he must register or log in first, with the option to register (button) and the option to log in (link).
Once he presses on one of them (either) he is directed to the login/signup screen and afterwards he is not directed to the original page…
i tried putting the code inside the signup/login promise (it doesn’t work - probably because that code is in the lightbox)
I tried putting that code inside the promise of the lightbox closure (it still doesn’t work - probably because the signup/login is called at that stage)
Your help is highly appreciated