Rewrite the post login example to use events