Class: Lesli::DeviseMailer

Inherits:
ApplicationLesliMailer show all
Defined in:
app/mailers/lesli/devise_mailer.rb

Instance Method Summary collapse

Methods inherited from ApplicationLesliMailer

#initialize

Constructor Details

This class inherits a constructor from Lesli::ApplicationLesliMailer

Instance Method Details

#confirmation_instructions(user, token, opts = {}) ⇒ Object

Sends an email to allow the user confirm the email address



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'app/mailers/lesli/devise_mailer.rb', line 29

def confirmation_instructions(user, token, opts = {})

    # defaults for new accounts/users
    email_template = "confirmation_instructions"
    email_subject = I18n.t("core.users/confirmations.mailer_email_verification")

    # # custom email and subject if user is changin his email address
    # if !record.unconfirmed_email.blank?
    #     email_template = "update_email_confirmation_instructions"
    #     email_subject = I18n.t("core.users/confirmations.mailer_confirmation_instructions_subject")
    # end

    # Depending on wheter there is a new user or they are changing their email, 
    # one or another field will be used
    email_recipient = user.unconfirmed_email || user.email

    # email parameters
    params = {
        url: "/confirmation?confirmation_token=#{token}"
    }

    # send email
    email(
        params,
        to: email_recipient, 
        subject: email_subject,
        template_name: email_template
    )
end

#reset_password_instructions(user, token, opts = {}) ⇒ Object

Sends an email with instructions to allow the user reset the password



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/mailers/lesli/devise_mailer.rb', line 7

def reset_password_instructions(user, token, opts = {})

    # defaults for new accounts/users
    email_template = "reset_password_instructions"
    email_subject = I18n.t("core.users/confirmations.mailer_email_verification")

    # email parameters
    params = {
        url: "/password/edit?reset_password_token=#{token}",
        user_name: user.full_name
    }

    # send email
    pp email(
        params,
        to: user.email, 
        subject: email_subject,
        template_name: email_template
    )
end