Implementation of a generic backend of eshop in Crystal
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

22 Zeilen
667 B

vor 6 Jahren
vor 6 Jahren
vor 6 Jahren
  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