require "crypto/bcrypt/password"
require "jennifer/model/authentication"

module ContainerMom::Models
  class User < Jennifer::Model::Base
    with_timestamps

    mapping(
      id: Primary64,
      email: String,
      password_hash: String,
      name: String?,
      created_at: Time?,
      updated_at: Time?
    )

    has_many :api_tokens, ApiToken
    has_many :container_deployments, ContainerDeployment

    validates_presence :email
    validates_presence :password_hash
    validates_uniqueness :email
  end
end
