Skip to content

Instantly share code, notes, and snippets.

@sebastjan-hribar
Created March 13, 2016 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebastjan-hribar/beee1aec40d19d0b2e7b to your computer and use it in GitHub Desktop.
Save sebastjan-hribar/beee1aec40d19d0b2e7b to your computer and use it in GitHub Desktop.
require 'bcrypt'
class Parent
include Hanami::Entity
attributes :name, :surname, :email, :password,
:password_confirmation, :password_reset_token, :password_reset_sent_at
attr_reader :password_hash, :password_salt
def password_salt
unless password.nil?
self.password_salt = BCrypt::Engine.generate_salt
end
end
def password_hash(password_salt)
unless password.nil?
self.password_hash = BCrypt::Engine.hash_secret(password, password_salt)
end
end
#.
#.
#.
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment