<%= form.label :password, "New password", style: "display: block" %>
<%= form.password_field :password, required: true, autofocus: true, autocomplete: "new-password" %>
12 characters minimum.
+
<%= form.label :password_confirmation, "Confirm new password", style: "display: block" %>
<%= form.password_field :password_confirmation, required: true, autocomplete: "new-password" %>
- <%= form.submit "Save changes" %>
+ <%= form.submit "Save changes", class: "btn btn-primary" %>
<% end %>
diff --git a/lib/action_auth/configuration.rb b/lib/action_auth/configuration.rb
index 72138a9..8df28aa 100644
--- a/lib/action_auth/configuration.rb
+++ b/lib/action_auth/configuration.rb
@@ -14,6 +14,7 @@ def initialize
@allow_user_deletion = true
@default_from_email = "from@example.com"
@magic_link_enabled = true
+ @pwned_enabled = defined?(Pwned)
@verify_email_on_sign_in = true
@webauthn_enabled = defined?(WebAuthn)
@webauthn_origin = "http://localhost:3000"
@@ -21,16 +22,20 @@ def initialize
end
def allow_user_deletion?
- @allow_user_deletion.respond_to?(:call) ? @allow_user_deletion.call : @allow_user_deletion
+ @allow_user_deletion == true
end
def magic_link_enabled?
- @magic_link_enabled.respond_to?(:call) ? @magic_link_enabled.call : @magic_link_enabled
+ @magic_link_enabled == true
end
def webauthn_enabled?
@webauthn_enabled.respond_to?(:call) ? @webauthn_enabled.call : @webauthn_enabled
end
+ def pwned_enabled?
+ @pwned_enabled.respond_to?(:call) ? @pwned_enabled.call : @pwned_enabled
+ end
+
end
end
diff --git a/test/controllers/action_auth/registrations_controller_test.rb b/test/controllers/action_auth/registrations_controller_test.rb
index 313e191..7e1db67 100644
--- a/test/controllers/action_auth/registrations_controller_test.rb
+++ b/test/controllers/action_auth/registrations_controller_test.rb
@@ -12,7 +12,7 @@ class RegistrationsControllerTest < ActionDispatch::IntegrationTest
test "should sign up" do
assert_difference("ActionAuth::User.count") do
email = "#{SecureRandom.hex}@#{SecureRandom.hex}.com"
- post sign_up_path, params: { email: email, password: "123456789012", password_confirmation: "123456789012" }
+ post sign_up_path, params: { email: email, password: email, password_confirmation: email }
end
assert_response :redirect
end
@@ -20,7 +20,15 @@ class RegistrationsControllerTest < ActionDispatch::IntegrationTest
test "should not sign up" do
assert_no_difference("ActionAuth::User.count") do
email = "#{SecureRandom.hex}@#{SecureRandom.hex}.com"
- post sign_up_path, params: { email: email, password: "1234567890AB", password_confirmation: "123456789012" }
+ post sign_up_path, params: { email: email, password: email, password_confirmation: "123456789012" }
+ end
+ assert_response :unprocessable_entity
+ end
+
+ test "should not sign up with pwned password" do
+ assert_no_difference("ActionAuth::User.count") do
+ email = "#{SecureRandom.hex}@#{SecureRandom.hex}.com"
+ post sign_up_path, params: { email: email, password: "Password1234", password_confirmation: "Password1234" }
end
assert_response :unprocessable_entity
end
diff --git a/test/mailers/action_auth/user_mailer_test.rb b/test/mailers/action_auth/user_mailer_test.rb
index bcca0f5..0f1ff15 100755
--- a/test/mailers/action_auth/user_mailer_test.rb
+++ b/test/mailers/action_auth/user_mailer_test.rb
@@ -17,5 +17,11 @@ class UserMailerTest < ActionMailer::TestCase
assert_equal "Verify your email", mail.subject
assert_equal [@user.email], mail.to
end
+
+ test "magic_link" do
+ mail = ActionAuth::UserMailer.with(user: @user).magic_link
+ assert_equal "Sign in to your account", mail.subject
+ assert_equal [@user.email], mail.to
+ end
end
end