correct handling of login events both ajax and normal form login