Implementation of a generic backend of eshop in Crystal
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

22 строки
667 B

6 лет назад
6 лет назад
6 лет назад
5 лет назад
6 лет назад
  1. require "json"
  2. require "uuid"
  3. require "uuid/json"
  4. require "crypto/bcrypt/password"
  5. require "./invoice"
  6. enum UserType
  7. Normal=0,
  8. Administrator=1,
  9. end
  10. class User
  11. JSON.mapping(
  12. addresses: {type: Array(Address), nilable: true},
  13. invoices: {type: Array(Invoice), nilable: true},
  14. tokens: {type: Array(UUID), nilable: true},
  15. email: String,
  16. password_hash: {type: String, nilable: true},
  17. active: {type: Bool, default: false},
  18. type: {type: UserType, default: UserType::Normal},
  19. )
  20. def initialize(@email, @active = false, @type = UserType::Normal) end
  21. end