Skip to content

Commit

Permalink
Remove some old pre-bundler code
Browse files Browse the repository at this point in the history
  • Loading branch information
tiegz committed Mar 27, 2014
1 parent 9870375 commit c2eae1c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
16 changes: 6 additions & 10 deletions lib/authlogic/crypto_providers/bcrypt.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
begin
require "bcrypt"
rescue LoadError
"sudo gem install bcrypt-ruby"
end
require "bcrypt"

module Authlogic
module CryptoProviders
Expand Down Expand Up @@ -55,19 +51,19 @@ def cost
@cost ||= 10
end
attr_writer :cost

# Creates a BCrypt hash for the password passed.
def encrypt(*tokens)
::BCrypt::Password.create(join_tokens(tokens), :cost => cost)
end

# Does the hash match the tokens? Uses the same tokens that were used to encrypt.
def matches?(hash, *tokens)
hash = new_from_hash(hash)
return false if hash.blank?
hash == join_tokens(tokens)
end

# This method is used as a flag to tell Authlogic to "resave" the password upon a successful login, using the new cost
def cost_matches?(hash)
hash = new_from_hash(hash)
Expand All @@ -77,12 +73,12 @@ def cost_matches?(hash)
hash.cost == cost
end
end

private
def join_tokens(tokens)
tokens.flatten.join
end

def new_from_hash(hash)
begin
::BCrypt::Password.new(hash)
Expand Down
8 changes: 2 additions & 6 deletions lib/authlogic/crypto_providers/scrypt.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
begin
require "scrypt"
rescue LoadError
"sudo gem install scrypt"
end
require "scrypt"

module Authlogic
module CryptoProviders
Expand Down Expand Up @@ -67,7 +63,7 @@ def matches?(hash, *tokens)
def join_tokens(tokens)
tokens.flatten.join
end

def new_from_hash(hash)
begin
::SCrypt::Password.new(hash)
Expand Down

0 comments on commit c2eae1c

Please sign in to comment.