benedmunds / CodeIgniter-Ion-Auth

Simple and Lightweight Auth System for CodeIgniter
http://benedmunds.com/ion_auth/
MIT License
2.35k stars 1.14k forks source link

Update IonAuthModel.php #1506

Closed DrAliRagab closed 3 years ago

DrAliRagab commented 3 years ago

I think you should have function to resend activation email if the first one was not sent successfully. Depending on that code I think I made a working function.

The only problem I can't get identity to be sent to email activation, I tried but I failed. I don't know how to get the identity field. Actually I didn't tried that hard because I don't need it at activation email, I just want first and last name.

benedmunds commented 3 years ago

Thanks for this PR, this seems like a great addition. Here are a couple of changes to consider:

  1. Move this method to the library, since it's where the other email logic lives and it's not data related
  2. Remove deactivation from this method, it should only send the email (if the user is deactivated)
  3. Rename to SendActivationEmail, and refactor the register method to call this method instead of sending it's own email directly

To resend emails I would expect the controller logic to be something like $this->ionAuth->deactivate($user->id)->sendActivationEmail($user->identity).

Also, please combine the changes from #1507 into this PR. I'll be closing that one.

DrAliRagab commented 3 years ago

I think it is better to keep register and send email activation to separate functions. And we should keep deactivate so we change the activation link every new request.

benedmunds commented 3 years ago

This is looking great.

One last thing, can you refactor the register() method to use sendActivationEmail(), that way we're reducing the duplicated code there.

DrAliRagab commented 3 years ago

While working I want to send email to user if his password changed successfully. So I wrote sendEmail() function. I think it will reduce duplicated code here. Also, may be useful for further expansion of this Auth system.

DrAliRagab commented 3 years ago

Good review.

benedmunds commented 3 years ago

Thanks!