added login middleware