Browse Source

Add authentication mailer

Maarten van den Berg 8 years ago
parent
commit
2ab4598d90

+ 13 - 0
app/mailers/authentication_mailer.rb

@@ -0,0 +1,13 @@
1
+class AuthenticationMailer < ApplicationMailer
2
+  def password_reset_email(user)
3
+    token = Token.new
4
+    token.user = user
5
+    token.tokentype = Token::TYPES[:password_reset]
6
+    token.save!
7
+
8
+    @token = token
9
+    @user = user
10
+
11
+    mail(to: @user.email, subject: "Aardbei-wachtwoord opnieuw instellen")
12
+  end
13
+end

+ 9 - 0
app/views/authentication_mailer/password_reset_email.text.erb

@@ -0,0 +1,9 @@
1
+Hallo <%= @user.person.first_name %>,
2
+
3
+Er is een verzoek binnengekomen om je wachtwoord opnieuw in te stellen.
4
+Als jij dit hebt gedaan, open dan deze link:
5
+
6
+Als je dit niet was kan je deze mail negeren.
7
+
8
+Doei,
9
+Aardbei

+ 7 - 0
test/mailers/authentication_mailer_test.rb

@@ -0,0 +1,7 @@
1
+require 'test_helper'
2
+
3
+class AuthenticationMailerTest < ActionMailer::TestCase
4
+  # test "the truth" do
5
+  #   assert true
6
+  # end
7
+end

+ 4 - 0
test/mailers/previews/authentication_mailer_preview.rb

@@ -0,0 +1,4 @@
1
+# Preview all emails at http://localhost:3000/rails/mailers/authentication_mailer
2
+class AuthenticationMailerPreview < ActionMailer::Preview
3
+
4
+end