How to implement email confirmation when removing a user in Yii -


In my project, I need to implement the following functionality: - When the user decides to delete his or her account, Before, an email must be sent to a user by confirming the decision by emailing an '$ Deletion URL'. I'm using the Yiimailer extension and although it's working fine, I'm not sure that the user's removal About me and other conditions Where and how should be kept. This is my verb: delete:

  Delete public function action ($ id) {$ this- & gt; LoadModel ($ id) - & gt; Remove (); If (! Isset ($ _GET ['ajax'])) {$ this- & gt; Redirect (isset ($ _ POST ['returnUrl']) $ $ _POST ['returnUrl']: array ('administrator')); }}   

I was researching on the internet and found that remove a CActiveRecord safe method ()

  before the protected function (delete) {If ($ this- & gt; Heaven Handler ('On Banner Delay')) {$ event = new CModelEvent ($ this); $ This- & gt; OnBeforeDelete ($ event); Return $ event- & gt; IsValid; } Revert to the truth; }   

But it is not certain how to optimize it in my case. And what's the other way to do this?

I have been able to resolve this issue in the following ways: My work in UserController:

  Delete public function actions ($ id) {$ model = $ this- & gt; LoadModel ($ id); $ Deletion URL = Yii :: app () - & gt; Make AABSQLUUural ('user / confirmation', array ('aHash' =>> $ model-> aHash)); $ Message = new YiiMailer (); $ Message & gt; setview ('contact'); $ Message & gt; setBody ($ deletionUrl); $ Message- & gt; Setdata (array ('message' = & gt; 'You received this email because you requested the deletion of your account. If you did not make this request, please ignore this email. Take action. & Lt; bell & gt; to confirm that your request was correct, confirm your request, it prevents unwanted spam and malicious abuse. Your accounts To confirm the removal, just follow the following link: '$$ deletion url.' & Lt; br & gt; & lt; br & gt; (Some email client users may have to copy and paste links into their web browser ',' Name '= & gt;' your name@123.com ',' description '= & gt;' Please click on the link below to confirm your request: ')); $ Message & gt; setLayout ('mail'); $ Message & gt; IsSMTP (); $ Message- & gt; setSubject ('request to delete account'); $ Message- & gt; Host = 'smtp.123.com'; $ Message- & gt; SMTPAuth = true; $ Message- & gt; Username = 'yourname@123.com'; $ Message- & gt; Password = 'yourpassword'; $ Message- & gt; Setfram ('your name@123.com', 'yourname'); $ Message & gt; setTo ($ Model & gt; aEmail); If ($ message-> Send ()) {$ this-> Render ('Removable'); Confirm in User Controller ():  
  Confirm Public Function Actions () {$ Models = User :: Models () - & gt; FindByAttributes (array ('aHash' = & gt; $ _GET ['aHash'])); If ($ Model === Faucet) Throw New CHttpException (404, 'Not Found'); Other {$ this- & gt; Load model ($ model- & amp; aUserID) - & gt; Remove (); $ Models & gt; Save (); $ This- & gt; Render ('afterdelete'); }}    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -