Version 2.0 - added redirect to the visited url after login