account.rb 541 B

12345678910111213141516171819202122232425262728293031323334353637
  1. script "serdes.rb"
  2. class Account
  3. include Serdes
  4. serdes_reader :id
  5. serdes_reader :pass
  6. serdes_reader :algo
  7. def inspect
  8. "Account #{@id} #{@pass} #{algo}"
  9. end
  10. def password=(pass)
  11. @algo = "crypt"
  12. @pass = crypt(pass)
  13. end
  14. # Returns true if the password matches that of this account or false if not.
  15. def challenge?(trypass)
  16. if algo == "plain"
  17. return @pass == trypass
  18. elsif algo == "crypt"
  19. return crypt_challenge(trypass, @pass)
  20. else
  21. return false
  22. end
  23. end
  24. end