devise_authenticator 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,5 +13,8 @@ module DeviseAuthenticator
13
13
  hashed_password = BCrypt::Engine.hash_secret("#{password}#{@@config.pepper}", bc.salt)
14
14
  hashed_password == encrypted_password
15
15
  end
16
- module_function :setup, :valid_password?
16
+ def hash_password(password)
17
+ BCrypt::Password.create("#{password}#{@@config.pepper}").to_s
18
+ end
19
+ module_function :setup, :valid_password?, :hash_password
17
20
  end
@@ -1,3 +1,3 @@
1
1
  module DeviseAuthenticator
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -3,11 +3,17 @@ require 'spec_helper'
3
3
  describe DeviseAuthenticator do
4
4
  let(:password){"w00tw00t"}
5
5
  let(:encrypted_password){"$2a$10$EYBGqTSJs6GKH0T3Rw7zrefN1kBMOfwD0v9GOccq1BnIVDEcQ4aU."}
6
- it "should generate devise hash for a given password" do
6
+ before(:each) do
7
7
  DeviseAuthenticator.setup do |config|
8
8
  config.pepper = "42888246834065a0e7b0c1ca33997e3ed1aede62abe8062328acf4b8e64ca979d8d22ccf54b1c5bca19c6098d0050b500fe77b9c5aeb4f4a6a182f415eb439db"
9
9
  config
10
10
  end
11
+ end
12
+ it "should authenticate against an existing devise hash" do
11
13
  DeviseAuthenticator.valid_password?(password, encrypted_password).should == true
12
14
  end
15
+ it "should generate a devise-compatible hash for a given password" do
16
+ hashed_pw = DeviseAuthenticator.hash_password(password)
17
+ DeviseAuthenticator.valid_password?(password, hashed_pw).should == true
18
+ end
13
19
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise_authenticator
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Douglas Campos