added error messgin and login redirect