Sha256: 9bb8ad39edae89980de8696e4b77131680a701a9b1fdc66eebf0331f71773604
Contents?: true
Size: 1.44 KB
Versions: 1
Compression:
Stored size: 1.44 KB
Contents
require 'ffi' module PythiaClient extend FFI::Library # ffi_lib "#{File.dirname(__FILE__)}/../rust/target/release/libpythia_ruby.so" ffi_lib "#{File.dirname(__FILE__)}/libpythia_ruby.so" attach_function :get_prf_value, [ :string, :string ], :string end module Pythia extend ActiveSupport::Concern MAX_PASSWORD_LENGTH_ALLOWED = 30 def get_pythia_password(unencrypted_password) # TODO: Use tweak properly pw_hash = PythiaClient::get_prf_value(unencrypted_password,"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") # puts "Hash received as:#{pw_hash}" pw_hash end module ClassMethods def has_pythia_password(options = {}) include InstanceMethodsOnActivation end end module InstanceMethodsOnActivation def authenticate(unencrypted_password) check = get_pythia_password(unencrypted_password) check.eql?(password_digest) && self end attr_reader :password def password=(unencrypted_password) if unencrypted_password.nil? self.password_digest = nil elsif !unencrypted_password.empty? @password = unencrypted_password self.password_digest = get_pythia_password(@password) if self.password_digest.nil? @password = nil end end end def password_confirmation=(unencrypted_password) @password_confirmation = unencrypted_password end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pythia-0.0.3-x86_64-linux | lib/pythia.rb |