Guest User

Untitled

a guest
Jul 30th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. def after_save
  2. # Assuming that this method is called on record creation and update
  3. # First, let's see if there's an existing record we need to update
  4. sub = LcrSubscriber.find_by_username(self.login) || LcrSubscriber.new
  5. sub.username = self.login
  6. sub.domain = ENV['SIP_DOMAIN']
  7. sub.password = ENV['DEFAULT_PASSWORD']
  8. sub.ha1 = Digest::MD5.hexdigest("#{sub.username}:#{sub.domain}:#{sub.password}")
  9. sub.ha1b = Digest::MD5.hexdigest("#{sub.username}@#{sub.domain}:#{sub.domain}:#{sub.password}")
  10. sub.save!
  11. end
Add Comment
Please, Sign In to add comment