Fixed the bug when logging in with a next url, respect that