Magento has a feature to redirect to the referrer page after a customer logs in.
I have done this using the following code:
$referer_url = $this->_redirect->getRefererUrl();
$CustomRedirectionUrl = $url->getUrl('customer/account/login',
array('referer' => base64_encode($referer_url)));
But this referrer URL is not working with Facebook/Google
signup; it is redirecting to the My Account
page.