Browse Source

Only allow active users to log in

pull/624/head
Kat 3 years ago
parent
commit
78fcc67104
  1. 4
      app/models/user.rb
  2. 16
      spec/features/user_spec.rb

4
app/models/user.rb

@ -142,4 +142,8 @@ class User < ApplicationRecord
def can_toggle_active?(user) def can_toggle_active?(user)
self != user && (support? || data_coordinator?) self != user && (support? || data_coordinator?)
end end
def valid_for_authentication?
super && active?
end
end end

16
spec/features/user_spec.rb

@ -172,6 +172,22 @@ RSpec.describe "User Features" do
end end
end end
context "when the user is trying to log in with deactivated user" do
before do
user.update!(active: false)
end
it "shows a gov uk error summary and no flash message" do
visit("/logs")
fill_in("user[email]", with: user.email)
fill_in("user[password]", with: "pAssword1")
click_button("Sign in")
expect(page).to have_selector("#error-summary-title")
expect(page).to have_no_css(".govuk-notification-banner.govuk-notification-banner--success")
expect(page).to have_title("Error")
end
end
context "when signed in as a data provider" do context "when signed in as a data provider" do
context "when viewing your account" do context "when viewing your account" do
before do before do

Loading…
Cancel
Save