adding middleware functions to process login and access