Check a valid user object was created before calling ->getId() on it

Bug: 65099
Change-Id: Ib8d290f1429e04faeb521c43841c1737b8be7ff8