Skip to content

Commit bb37118

Browse files
enescakirjeremyevans
authored andcommitted
Make rodauth.has_password? method public
I needed this method when integrating rodauth-omniauth into our project. If an account is created via omniauth, it doesn't have a password. In this case, I prefer to display "Create Password" instead of "Change Password". Additionally, if the omniauth provider is the last authentication method, including the password, I aim to block to disconnect it. Therefore, I believe this method is beneficial to have in public.
1 parent 3921088 commit bb37118

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

CHANGELOG

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
=== master
2+
* Make rodauth.has_password? method public (enescakir) (#461)
23

34
* Fix strict_unused_block warnings when running specs on Ruby 3.4 (jeremyevans)
45

lib/rodauth/features/base.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,12 @@ def possible_authentication_methods
542542
has_password? ? ['password'] : []
543543
end
544544

545+
def has_password?
546+
return @has_password if defined?(@has_password)
547+
return false unless account || session_value
548+
@has_password = !!get_password_hash
549+
end
550+
545551
private
546552

547553
def _around_rodauth
@@ -718,12 +724,6 @@ def function_name(name)
718724
end
719725
end
720726

721-
def has_password?
722-
return @has_password if defined?(@has_password)
723-
return false unless account || session_value
724-
@has_password = !!get_password_hash
725-
end
726-
727727
def password_hash_using_salt(password, salt)
728728
BCrypt::Engine.hash_secret(password, salt)
729729
end

0 commit comments

Comments
 (0)