Fix bug where no redirection to login after failed login
Add login-required middleware