added login part and handled the routes and flash messages