A High Court judge rules the decision to give permission for the mine was “legally flawed”.