Improved login auto-redirect