added authentication and flash messages