Module: Authpwn::SessionMailer

Included in:
SessionMailer
Defined in:
lib/authpwn_rails/session_mailer.rb

Overview

Included by the session mailer class.

Parts of the codebase assume the mailer will be named SessionMailer.

Instance Method Summary collapse

Instance Method Details

#email_verification_email(token, root_url) ⇒ Object

Creates an e-mail containing a verification token for the e-mail address.

Parameters:

  • token (String)

    the e-mail confirmation token

  • the (String)

    application’s root URL (e.g. “localhost:3000/”)



12
13
14
15
16
17
18
19
20
21
# File 'lib/authpwn_rails/session_mailer.rb', line 12

def email_verification_email(token, root_url)
  @token = token
  @protocol, @host = *root_url.split('://', 2)
  @host.slice!(-1) if @host[-1] == ?/
  hostname = @host.split(':', 2).first  # Strip out any port.

  mail to: @token.email,
       subject: email_verification_subject(token, hostname, @protocol),
       from: email_verification_from(token, hostname, @protocol)
end

#email_verification_from(token, server_hostname, protocol) ⇒ Object

The sender e-mail address for an e-mail verification e-mail.

The authpwn generator encourages applications to override this method.



33
34
35
# File 'lib/authpwn_rails/session_mailer.rb', line 33

def email_verification_from(token, server_hostname, protocol)
  %Q|"#{server_hostname} staff" <admin@#{server_hostname}>|
end

#email_verification_subject(token, server_hostname, protocol) ⇒ Object

The subject line in an e-mail verification e-mail.

The authpwn generator encourages applications to override this method.



26
27
28
# File 'lib/authpwn_rails/session_mailer.rb', line 26

def email_verification_subject(token, server_hostname, protocol)
  "#{server_hostname} e-mail verification"
end

#reset_password_email(email, token, root_url) ⇒ Object

Creates an e-mail containing a password reset token.

Parameters:

  • email (String)

    the email to send the token to

  • token (String)

    the password reset token

  • root_url (String)

    the application’s root URL (e.g. “localhost:3000/”)



43
44
45
46
47
48
49
50
51
52
# File 'lib/authpwn_rails/session_mailer.rb', line 43

def reset_password_email(email, token, root_url)
  @email, @token, @host, @protocol = email, token
  @token = token
  @protocol, @host = *root_url.split('://', 2)
  @host.slice!(-1) if @host[-1] == ?/

  hostname = @host.split(':', 2).first  # Strip out any port.
  mail to: email, from: reset_password_from(token, hostname, @protocol),
       subject: reset_password_subject(token, hostname, @protocol)
end

#reset_password_from(token, server_hostname, protocol) ⇒ Object

The sender e-mail address for a password reset e-mail.

The authpwn generator encourages applications to override this method.



64
65
66
# File 'lib/authpwn_rails/session_mailer.rb', line 64

def reset_password_from(token, server_hostname, protocol)
  %Q|"#{server_hostname} staff" <admin@#{server_hostname}>|
end

#reset_password_subject(token, server_hostname, protocol) ⇒ Object

The subject line in a password reset e-mail.

The authpwn generator encourages applications to override this method.



57
58
59
# File 'lib/authpwn_rails/session_mailer.rb', line 57

def reset_password_subject(token, server_hostname, protocol)
  "#{server_hostname} password reset"
end