Created
May 23, 2011 17:26
-
-
Save elricstorm/987103 to your computer and use it in GitHub Desktop.
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
<!-- ui-dialog --> | |
<div id="dialog-password-forget-form"> | |
<%= form_tag forgot_password_path, :id => "submit-forgot-password" do %> | |
<fieldset id="user-email"> | |
<p> | |
<label>Email address<span><%= email_field_tag :email, '', :id => "email" %></span></label> | |
</p> | |
</fieldset> | |
<% end %> | |
</div> |
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
<h1>Password Reset Code Has Been Mailed</h1> | |
<p>Please check your email account and follow the instructions we mailed to you.</p> |
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 will create a password reset code for the user and mail them instructions | |
# we'll process this as a post request | |
match '/forgot_password' => "sessions#forgot_password", :as => "forgot_password", :via => :post |
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
# FORGOT_PASSWORD /forgot_password(:format) via POST request | |
def forgot_password | |
# let's find the user by the email params specified | |
user = User.find_by_email(params[:email]) | |
respond_to do |format| | |
# if the email address matched a user's email address then the user | |
# object should be valid and processing will continue, else it will | |
# redirect the requester to the login path and supply a message. | |
if user | |
# Send the user id to the user model's forgot_password method | |
user.forgot_password(user) | |
format.html | |
format.xml { render :xml => @user } | |
else | |
# The user provided an incorrect email address. | |
format.html { redirect_to(login_path, :notice => 'The email address you provided could not be found.') } | |
format.mobile { redirect_to(mobile_forgot_password_path, :notice => 'The email address you provided could not be found.') } | |
format.xml { render :xml => user.errors, :status => :unprocessable_entity } | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment