I think it's trying to redirect to previous page, but previous page is login page.
That's not previous page already and it's not possible to provide this page to login controller as it's not http referrer.
That could be most probably insecure method, but will review it again.