Refactor signup and login validation