fix bug for casting anonymousUser to user object