Unveiling the redback nature of the low-mass X-ray binary XSS J1227.0−4859 through optical observations