Don't show users password change page if ldap users

This commit is contained in:
Izaak Alpert 2013-09-17 16:37:36 -04:00
parent 16b6040c2e
commit ca1b67ce38
4 changed files with 40 additions and 1 deletions

View file

@ -151,7 +151,7 @@ class ApplicationController < ActionController::Base
end end
def check_password_expiration def check_password_expiration
if current_user && current_user.password_expires_at && current_user.password_expires_at < Time.now if current_user && current_user.password_expires_at && current_user.password_expires_at < Time.now && !current_user.ldap_user?
redirect_to new_profile_password_path and return redirect_to new_profile_password_path and return
end end
end end

View file

@ -18,6 +18,7 @@ Feature: Profile
Scenario: My password is expired Scenario: My password is expired
Given my password is expired Given my password is expired
And I am not an ldap user
And I visit profile account page And I visit profile account page
Then I redirected to expired password page Then I redirected to expired password page
And I submit new password And I submit new password

View file

@ -91,6 +91,11 @@ class Profile < Spinach::FeatureSteps
current_user.update_attributes(password_expires_at: Time.now - 1.hour) current_user.update_attributes(password_expires_at: Time.now - 1.hour)
end end
step "I am not an ldap user" do
current_user.update_attributes(extern_uid: nil, provider: '')
current_user.ldap_user?.should be_false
end
step 'I redirected to expired password page' do step 'I redirected to expired password page' do
current_path.should == new_profile_password_path current_path.should == new_profile_password_path
end end

View file

@ -0,0 +1,33 @@
require 'spec_helper'
describe ApplicationController do
describe '#check_password_expiration' do
let(:user) { create(:user) }
let(:controller) { ApplicationController.new }
it 'should redirect if the user is over their password expiry' do
user.password_expires_at = Time.new(2002)
user.ldap_user?.should be_false
controller.stub!(:current_user).and_return(user)
controller.should_receive(:redirect_to)
controller.should_receive(:new_profile_password_path)
controller.send(:check_password_expiration)
end
it 'should not redirect if the user is under their password expiry' do
user.password_expires_at = Time.now + 20010101
user.ldap_user?.should be_false
controller.stub!(:current_user).and_return(user)
controller.should_not_receive(:redirect_to)
controller.send(:check_password_expiration)
end
it 'should not redirect if the user is over their password expiry but they are an ldap user' do
user.password_expires_at = Time.new(2002)
user.stub!(:ldap_user?).and_return(true)
controller.stub!(:current_user).and_return(user)
controller.should_not_receive(:redirect_to)
controller.send(:check_password_expiration)
end
end
end