Add some message flashing and fix some bugs in authentication, login and logout.