This repository has been archived by the owner on Jun 7, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
143 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
class PasswordResetsController < BaseController | ||
|
||
before_filter :require_no_user | ||
before_filter :load_user_using_perishable_token, :only => [ :edit, :update ] | ||
|
||
def new | ||
end | ||
|
||
def create | ||
@user = User.find_by_email(params[:email]) | ||
if @user | ||
@user.deliver_password_reset_instructions! | ||
|
||
flash[:info] = :your_password_reset_instructions_have_been_emailed_to_you.l | ||
|
||
redirect_to login_path | ||
else | ||
flash[:error] = :sorry_we_dont_recognize_that_email_address.l | ||
|
||
render :action => :new | ||
end | ||
end | ||
|
||
def edit | ||
end | ||
|
||
def update | ||
@user.password = params[:password] | ||
@user.password_confirmation = params[:password_confirmation] | ||
|
||
if @user.save | ||
flash[:notice] = :your_changes_were_saved.l | ||
|
||
redirect_to dashboard_user_path(@user) | ||
else | ||
flash[:error] = @user.errors.full_messages.to_sentence | ||
render :action => :edit | ||
end | ||
end | ||
|
||
|
||
private | ||
|
||
def load_user_using_perishable_token | ||
@user = User.find_using_perishable_token(params[:id]) | ||
unless @user | ||
flash[:error] = :an_error_occurred.l | ||
|
||
redirect_to login_path | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.yui-b.sidebar | ||
|
||
#yui-main | ||
.yui-b.main_column | ||
-box do | ||
%h3=:forgot_your_password.l | ||
|
||
- form_tag password_reset_path, :method => :put, :class => "MainForm" do | ||
%label=:password.l | ||
= password_field_tag :password | ||
|
||
%label=:confirm_password.l | ||
= password_field_tag :password_confirmation | ||
|
||
%p= submit_tag :reset_my_password.l | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Hi there! | ||
|
||
A request to reset your <%= AppConfig.community_name %> password has been made. If you did not make this request, simply ignore this email. If you did make this request, visit the URL below. | ||
|
||
<%= @edit_password_reset_url %> | ||
|
||
If you have any questions, please contact <%= AppConfig.community_name %> support at <%= AppConfig.support_email %>. | ||
|
||
Thanks, | ||
The <%= AppConfig.community_name %> team |
5 changes: 3 additions & 2 deletions
5
...views/user_notifier/reset_password.fr.erb → ...tifier/password_reset_instructions.fr.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
require File.dirname(__FILE__) + '/../test_helper' | ||
|
||
class PasswordResetsControllerTest < ActionController::TestCase | ||
fixtures :all | ||
|
||
test "should get new and respond with success" do | ||
get :new | ||
|
||
assert_response :success | ||
end | ||
|
||
test "should post to create and send an email" do | ||
assert_emails 1 do | ||
post :create, :email => users(:quentin).email | ||
assert_response :redirect | ||
assert_redirected_to login_path | ||
end | ||
end | ||
|
||
test "should get edit and respond with success" do | ||
get :edit, :id => users(:quentin).perishable_token | ||
|
||
assert_response :success | ||
end | ||
|
||
test "should put to update and redirect to dashboard" do | ||
@user = users(:quentin) | ||
|
||
put :update, :id => @user.perishable_token, :user => { :password => "newpassword" } | ||
|
||
assert_redirected_to dashboard_user_path(@user) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters