Oops previous commit broke login.
This fixes that problem - checks to see if $user is set first