Factorize some user db related code to a base class.