Fix AttributeError in login hook