Refactored and moved code into the login model / observer domain where it belongs