extract method to check if a user exists in db

Change-Id: I8857cefdcf599df3157ca5e3778b09875c49e42f