An intelligent reflecting surface (IRS) is proposed to enhance the physical layer security in the Rician fading channel wherein the angular direction of the eavesdropper (ED) is aligned with a legitimate user. A two-phase communication system under active attacks and passive eavesdropping is considered in this scenario. The base station avoids direct transmission to the attacked user in the first phase, whereas other users cooperate in forwarding signals to the attacked user in the second phase, with the help of IRS and energy harvesting technology. Under the occurrence of active attacks, an outage-constrained beamforming design problem is investigated under the statistical cascaded channel error model, which is solved by using the Bernstein-type inequality. An average secrecy rate maximization problem for the passive eavesdropping is formulated, which is then addressed by a low-complexity algorithm. The numerical results of this study reveal that the negative effect of the ED's channel error is larger than that of the legitimate user.