Fix the email invitation flow

fix #83
fix #82