Permalink
Browse files

hash in ruby

  • Loading branch information...
nna774 committed Sep 16, 2018
1 parent 9bb6e3f commit e7440a9e64978d8cbe3e625b3a3d96fda2d7a54d
Showing with 2 additions and 1 deletion.
  1. +2 −1 app/webapp/ruby/lib/torb/web.rb
@@ -3,6 +3,7 @@
require 'erubi'
require 'mysql2'
require 'mysql2-cs-bind'
require 'openssl'
module Torb
class Web < Sinatra::Base
@@ -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']

0 comments on commit e7440a9

Please sign in to comment.