Created
November 20, 2010 00:20
-
-
Save kirkconnell/707463 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
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb | |
index 8b10472..3716fac 100644 | |
--- a/app/controllers/application_controller.rb | |
+++ b/app/controllers/application_controller.rb | |
@@ -6,7 +6,7 @@ class ApplicationController < ActionController::Base | |
filter_parameter_logging :password, :password_confirmation | |
helper_method :current_user, :signed_in?, :lawgical_employees, :client_lawgical_url, :profile_errors? | |
- before_filter :authenticate, :set_time_zone | |
+ before_filter :authenticate, :set_time_zone, :check_change_password | |
def next_unreconciled_entity(current_entity = nil) | |
current_entity_id = current_entity ? current_entity.id : 1 | |
@@ -115,6 +115,15 @@ class ApplicationController < ActionController::Base | |
@merged_core_entities.any? ? ["entities.created_at < ? AND entities.id NOT IN (?)", @release_execution_date, @merged_core_entities.map{|e| e.core_entity_id}] : | |
["entities.created_at < ?", @release_execution_date] | |
end | |
+ | |
+ def check_change_password | |
+ return if !signed_in? | |
+ if current_user.changeflag? | |
+ store_location | |
+ flash[:notice] = "Please update your password before continuing." | |
+ redirect_to edit_password_path | |
+ end | |
+ end | |
protected | |
diff --git a/app/controllers/passwords_controller.rb b/app/controllers/passwords_controller.rb | |
index 4463ee6..c137793 100644 | |
--- a/app/controllers/passwords_controller.rb | |
+++ b/app/controllers/passwords_controller.rb | |
@@ -1,4 +1,5 @@ | |
class PasswordsController < ApplicationController | |
+ skip_before_filter [:check_change_password] | |
def edit | |
@user = current_user | |
diff --git a/features/authenticate.feature b/features/authenticate.feature | |
index d65e193..99845e5 100644 | |
--- a/features/authenticate.feature | |
+++ b/features/authenticate.feature | |
@@ -31,3 +31,14 @@ Feature: Authentication | |
| session_password | password | | |
And I press "session_submit" | |
And I should be redirected to client lawgical login | |
+ | |
+ Scenario: A nerd wants me to change my password | |
+ Given I am an employee "[email protected]"/"password" | |
+ And A nerd wants me to change my password | |
+ And I am on the login page | |
+ When I fill in the following: | |
+ | session_email | [email protected] | | |
+ | session_password | password | | |
+ And I press "session_submit" | |
+ Then I should be on the edit password page | |
+ And I should see "Please update your password before continuing." | |
diff --git a/features/step_definitions/user_steps.rb b/features/step_definitions/user_steps.rb | |
index 4fb63a6..69dbd21 100644 | |
--- a/features/step_definitions/user_steps.rb | |
+++ b/features/step_definitions/user_steps.rb | |
@@ -35,4 +35,8 @@ end | |
Then /^I should be redirected to client lawgical login$/ do | |
current_url.to_s.should =~ /lawgical\.local/ | |
-end | |
\ No newline at end of file | |
+end | |
+ | |
+Given /^A nerd wants me to change my password$/ do | |
+ @current_user.update_attribute :changeflag, true | |
+end | |
diff --git a/features/support/paths.rb b/features/support/paths.rb | |
index f24351b..9b91eb7 100644 | |
--- a/features/support/paths.rb | |
+++ b/features/support/paths.rb | |
@@ -60,6 +60,8 @@ module NavigationHelpers | |
accounting_path | |
when /^the ServeManager admin website$/i | |
"http://smadmin.local" | |
+ when /^the edit password page$/i | |
+ edit_password_path | |
else | |
raise "Can't find mapping from \"#{page_name}\" to a path.\n" + | |
"Now, go and add a mapping in #{__FILE__}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment