Referrer redirection

Checkout this code to see if it is a good implementation of  redirecting to the last attempted URL on successful sign-in.