forked from binarylogic/authlogic_example
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added reset password f functionality
- Loading branch information
1 parent
64e3ab7
commit 8bbc485
Showing
11 changed files
with
102 additions
and
5 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,11 @@ | ||
class Notifier < ActionMailer::Base | ||
default_url_options[:host] = "authlogic_example.binarylogic.com" | ||
|
||
def password_reset_instructions(user) | ||
subject "Password Reset Instructions" | ||
from "Binary Logic Notifier <noreply@binarylogic.com>" | ||
recipients user.email | ||
sent_on Time.now | ||
body :edit_password_url => edit_password_account_url(:password_reset_token => user.password_reset_token) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
class User < ActiveRecord::Base | ||
acts_as_authentic | ||
|
||
validates_presence_of :email | ||
validates_uniqueness_of :email | ||
|
||
def deliver_password_reset_instructions! | ||
reset_password_reset_token! | ||
Notifier.deliver_password_reset_instructions(self) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
A request to reset your password has been made. If you did not make this request, simply ignore this email. If you did make this request just click the link below: | ||
|
||
<%= @edit_password_url %> | ||
|
||
If the above URL does not work try copying and pasting it into your browser. If you continue to have problem please feel free to contact us. |
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,12 @@ | ||
<h1>Change My Password</h1> | ||
|
||
<% form_for @user, :url => update_password_account_path(:password_reset_token => params[:password_reset_token]) do |f| %> | ||
<%= f.error_messages %> | ||
<%= f.label :password %><br /> | ||
<%= f.password_field :password %><br /> | ||
<br /> | ||
<%= f.label :confirm_password %><br /> | ||
<%= f.password_field :confirm_password %><br /> | ||
<br /> | ||
<%= f.submit "Update my password and log me in" %> | ||
<% 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<h1>Forgot Password</h1> | ||
|
||
Fill out the form below and instructions to reset your password will be emailed to you:<br /> | ||
<br /> | ||
|
||
<% form_tag request_password_reset_account_path do %> | ||
<label>Email:</label><br /> | ||
<%= text_field_tag "email" %><br /> | ||
<br /> | ||
<%= submit_tag "Reset my password" %> | ||
<% 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
14 changes: 14 additions & 0 deletions
14
db/migrate/20081116172851_add_users_password_reset_fields.rb
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,14 @@ | ||
class AddUsersPasswordResetFields < ActiveRecord::Migration | ||
def self.up | ||
add_column :users, :password_reset_token, :string, :default => "", :null => false | ||
add_column :users, :email, :string, :default => "", :null => false | ||
|
||
add_index :users, :password_reset_token | ||
add_index :users, :email | ||
end | ||
|
||
def self.down | ||
remove_column :users, :password_reset_token | ||
remove_column :users, :email | ||
end | ||
end |