mcordell / grape_token_auth

Token auth for grape apps
MIT License
52 stars 19 forks source link

We should easily be able to override the mailer #15

Closed frobichaud closed 8 years ago

frobichaud commented 8 years ago

There should be a config that allows devs to override the mailer, perhaps something similar to: https://github.com/plataformatec/devise/wiki/How-To:-Use-custom-mailer

There should be a layer between the model#send_reset_password_instructions and the the configuration.mailer

mcordell commented 8 years ago

You should be able to override the mailer itself, for example, here I create a mailer for mail gun here. I then use it by configuring it here.

As for the messages themselves. You can inherit from the email class, e.g.password reset email and override it at will. Or you could define a class that defines the the public methods found here and do whatever you want in the message.

With your new class you can then configure GTA use it in the configuration as so:

GrapeTokenAuth.configuration do |config|
    config.messages = GrapeTokenAuth::Mail::DEFAULT_MESSAGES.merge(reset_password_instructions: YOUR_NEW_CLASS)
end

Does that make sense and meet the issue?

mcordell commented 8 years ago

@frobichaud see this wiki page: https://github.com/mcordell/grape_token_auth/wiki/Email

Let me know if you have any suggestions on improving the documentation. Closing this issue for now.