Added a login middleware and using it on needed endpoints