Skip to content

Commit fdd534e

Browse files
committed
check bcrypted passwords
1 parent deeee47 commit fdd534e

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ gem 'couchrest_model', '~> 1.1.0'
1111
gem 'sqlite3' # to keep ActiveRecord happy
1212
gem 'omniauth'
1313
gem 'oauth2'
14-
gem 'bcrypt-ruby'
14+
gem 'bcrypt-ruby', :require => 'bcrypt'
1515
gem 'slim'
1616
gem 'riemann-client'
1717

app/controllers/sessions_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def create
2222
if params[:password].nil?
2323
response.merge!(:status => "NEEDPASS")
2424
else
25-
if params[:password] == user.password
25+
if user.authentic?(params[:password])
2626
session[:logged_in_user] = user.username
2727
RIEMANN << {service:'icecondor user', tags:['login'],
2828
description:"user: #{user.username}"}

app/models/user.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,7 @@ def self.build_initial_locations(usernames, count)
4242
end
4343
end
4444

45+
def authentic?(pass)
46+
BCrypt::Password.new(password) == pass
47+
end
4548
end

0 commit comments

Comments
 (0)