Basically legal.
According to Article 6 of the Patent Law: Inventions and creations that are completed while performing the tasks of the unit or mainly by utilizing the material and technical conditions of the unit are service inventions. The right to apply for a patent for a service invention-creation belongs to the unit; after the application is approved, the unit becomes the patentee.
According to Article 12 of the Implementing Rules of the Patent Law: The term "service inventions and creations completed in performing the tasks of the unit" as mentioned in Article 6 of the Patent Law refers to: (3) after retirement, transfer from the original unit, or Inventions and creations made within one year after the termination of the labor or personnel relationship and related to the original work undertaken by the original unit or the tasks assigned by the original unit.