Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
hash in ruby
  • Loading branch information
nna774 committed Sep 16, 2018
1 parent 9bb6e3f commit e7440a9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/webapp/ruby/lib/torb/web.rb
Expand Up @@ -3,6 +3,7 @@
require 'erubi'
require 'mysql2'
require 'mysql2-cs-bind'
require 'openssl'

module Torb
class Web < Sinatra::Base
Expand Down Expand Up @@ -272,7 +273,7 @@ def render_report_csv(reports)
password = body_params['password']

user = db.xquery('SELECT * FROM users WHERE login_name = ?', login_name).first
pass_hash = db.xquery('SELECT SHA2(?, 256) AS pass_hash', password).first['pass_hash']
pass_hash = OpenSSL::Digest::SHA256.hexdigest(password)
halt_with_error 401, 'authentication_failed' if user.nil? || pass_hash != user['pass_hash']

session['user_id'] = user['id']
Expand Down

0 comments on commit e7440a9

Please sign in to comment.