Skip to content

Commit

Permalink
Merge pull request #149 from pozorvlak/password-reset
Browse files Browse the repository at this point in the history
Password reset - make emails friendlier and fix blank page
  • Loading branch information
pozorvlak committed Mar 27, 2013
2 parents 22b985b + 5d09386 commit 37e406d
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 28 deletions.
5 changes: 1 addition & 4 deletions app/views/devise/mailer/confirmation_instructions.html.haml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
- site_name = Growstuff::Application.config.site_name
%p
Welcome,
= @resource.login_name
!
%p Hello #{@resource.login_name},

%p
Your account on #{site_name} has been created. You just need to confirm
Expand Down
21 changes: 14 additions & 7 deletions app/views/devise/mailer/reset_password_instructions.html.haml
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
%p
Hello
= @resource.email
!
- site_name = Growstuff::Application.config.site_name
%p Hello #{@resource.login_name},

%p Someone has requested a link to change your password, and you can do this through the link below.
%p Someone has requested a link to reset your password on #{site_name}.
We presume this was you, in which case you can do so through this link:

%p
= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token)

%p If you didn't request this, please ignore this email.
%p Your password won't change until you access the link above and create a new one.
%p If it wasn't you, then someone's made a typo or has been messing
around. In this case, you can safely ignore this email, and your
password will not be changed.

%p See you soon,

%p The #{site_name} team.
%br/
=link_to root_url, root_url

25 changes: 16 additions & 9 deletions app/views/devise/mailer/unlock_instructions.html.haml
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
%p
Hello
= @resource.email
!
- site_name = Growstuff::Application.config.site_name
%p Hello #{@resource.login_name},

%p
Your account has been locked due to an excessive amount of unsuccessful sign
in attempts.
Your #{site_name} account has been locked due to an excessive number
of unsuccessful sign in attempts. We do this in case someone's trying
to break into your account, but it might also mean you've just
forgotten your password. In either case, use the link below to unlock
your account:

%p Click the link below to unlock your account:
%p= link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @resource.unlock_token)

%p
= link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @resource.unlock_token)
%p If you have actually forgotten your password, you can
= link_to 'reset your password', new_password_url(@resource)
after you've unlocked your account.

%p See you soon,
%p The #{site_name} team.
%br/
=link_to root_url, root_url
2 changes: 1 addition & 1 deletion app/views/devise/passwords/edit.html.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
- content_for :title, "Change your password"

- form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put }) do |f|
= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put }) do |f|
= devise_error_messages!
= f.hidden_field :reset_password_token

Expand Down
4 changes: 2 additions & 2 deletions config/locales/devise.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ en:
confirmation_instructions:
subject: 'Welcome to Growstuff. Please confirm your account.'
reset_password_instructions:
subject: 'Reset password instructions'
subject: 'Growstuff password reset instructions'
unlock_instructions:
subject: 'Unlock Instructions'
subject: 'Unlock your Growstuff account'
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

it 'should have some of the right text' do
rendered.should contain 'Change my password'
rendered.should contain 'please ignore this email'
rendered.should contain 'Someone has requested a link to reset your password'
end
end
end
7 changes: 3 additions & 4 deletions spec/views/devise/mailer/unlock_instructions_spec.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
require 'spec_helper'
describe 'devise/mailer/unlock_instructions.html.haml', :type => "view" do
context "logged in" do
before(:each) do
@resource = mock_model(Member)
@resource.should_receive(:email).and_return("example@example.com")
@resource.should_receive(:unlock_token).and_return("fred")
@resource = FactoryGirl.create(:member)
render
end

it "should explain what's happened" do
rendered.should contain "Your account has been locked"
rendered.should contain "account has been locked"
end

it "should have an unlock link" do
Expand Down

0 comments on commit 37e406d

Please sign in to comment.