Method of surface treatment of a material based on magnesium alloys