Fix error with using undeclared var 'user' which was causing dialog not to close. Also dispach a failure unless success is signalled