Skip to content
This repository has been archived by the owner on Feb 6, 2022. It is now read-only.

Commit

Permalink
Started on forgot password
Browse files Browse the repository at this point in the history
  • Loading branch information
aslakhellesoy committed Sep 23, 2008
1 parent 8819753 commit 284aaf9
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 1 deletion.
13 changes: 13 additions & 0 deletions app/models/default_forgot_password_part.html
@@ -0,0 +1,13 @@
<r:ba:if_flash key="reset_password_email_sent">
We have sent you an email that will allow you to reset the password.
</r:ba:if_flash>

<form method="post" action=".">
<p>
<label for="email">Email</label><br/>
<input id="email" type="text" name="email" value="<r:ba:request_param name="email" />"/>
</p>
<p>
<input type="submit" value="Send me a reset link" name="commit" />
</p>
</form>
24 changes: 24 additions & 0 deletions app/models/forgot_password_page.rb
@@ -0,0 +1,24 @@
class ForgotPasswordPage < Page
description %{
This page displays a page where people can ask for a reset password link.
}

before_validation_on_create :create_default_content

def cache?
false
end

def process(request, response)
super
end

def create_default_content
self.parent = Page.find_by_url('/')
self.slug = 'forgot'
self.breadcrumb = self.title = 'Forgot Password'
self.status = Status[:published]

parts << PagePart.new(:name => 'body', :content => read_file('default_forgot_password_part.html'))
end
end
9 changes: 9 additions & 0 deletions db/migrate/013_create_forgot_password_page.rb
@@ -0,0 +1,9 @@
class CreateForgotPasswordPage < ActiveRecord::Migration
def self.up
ForgotPasswordPage.create!
end

def self.down
ForgotPasswordPage.destroy_all
end
end
9 changes: 8 additions & 1 deletion features/account.feature
Expand Up @@ -19,4 +19,11 @@ Feature: Account
And I fill in "gibberish" for "Email"
And I press "Save"
Then "Aslak"'s Email should be "aslak@test.com"
And I should see "The Email address should look like an email address."
And I should see "The Email address should look like an email address."

Scenario: Receive reset password email
Given an "active" site_user named "Aslak" exists
When I view the forgot password page
And I fill in "aslak@test.com" for "Email"
And I press "Send me a reset link"
Then "aslak@test.com" should receive an email with reset code/
3 changes: 3 additions & 0 deletions features/steps/account_steps.rb
Expand Up @@ -29,3 +29,6 @@
visits "/account"
end

When /I view the forgot password page/ do
visits "/forgot"
end
1 change: 1 addition & 0 deletions lib/tasks/ba_extension_tasks.rake
Expand Up @@ -24,6 +24,7 @@ namespace :db do

LoginPage.create!(:layout => layout)
AccountPage.create!(:layout => layout)
ForgotPasswordPage.create!(:layout => layout)
end
end
end
Expand Down

0 comments on commit 284aaf9

Please sign in to comment.