Refactoring around redirect when login