extracted login logic to the login directive