Sha256: 273cd0530602ed64e3cbb8428934053b8e5f163ca41d3497923b91f362a1bafd

Contents?: true

Size: 1.28 KB

Versions: 82

Compression:

Stored size: 1.28 KB

Contents

require "digest/md5"
require "cgi"
require "gds-sso/user"
require "workflow_actor"
require "safe_html"

class User
  include Mongoid::Document
  include Mongoid::Timestamps
  include GDS::SSO::User
  include WorkflowActor

  # Let an app configure the collection name to use, e.g. set a constant in an
  # initializer
  def self.collection_name
    defined?(USER_COLLECTION_NAME) ? USER_COLLECTION_NAME : "users"
  end

  field "name",                type: String
  field "uid",                 type: String
  field "version",             type: Integer
  field "email",               type: String
  field "permissions",         type: Array
  field "remotely_signed_out", type: Boolean, default: false
  field "organisation_slug",   type: String
  
  GOVSPEAK_FIELDS = []

  # Setup accessible (or protected) attributes for your model
  attr_accessible :email, :name, :uid
  attr_accessible :email, :name, :uid, :permissions, as: :oauth

  scope :alphabetized, order_by(name: :asc)

  validates_with SafeHtml

  def to_s
    name || email || ""
  end

  def gravatar_url(opts = {})
    opts.symbolize_keys!
    "%s.gravatar.com/avatar/%s%s" % [
      opts[:ssl] ? "https://secure" : "http://www",
      Digest::MD5.hexdigest(email.downcase),
      opts[:s] ? "?s=#{CGI.escape(opts[:s])}" : ""
    ]
  end
end

Version data entries

82 entries across 82 versions & 1 rubygems

Version Path
govuk_content_models-23.0.0 app/models/user.rb
govuk_content_models-22.2.0 app/models/user.rb
govuk_content_models-22.1.2 app/models/user.rb
govuk_content_models-22.1.1 app/models/user.rb
govuk_content_models-22.1.0 app/models/user.rb
govuk_content_models-22.0.0 app/models/user.rb
govuk_content_models-21.0.0 app/models/user.rb
govuk_content_models-20.2.0 app/models/user.rb
govuk_content_models-20.1.0 app/models/user.rb
govuk_content_models-20.0.0 app/models/user.rb
govuk_content_models-19.0.0 app/models/user.rb
govuk_content_models-18.0.0 app/models/user.rb
govuk_content_models-17.2.1 app/models/user.rb
govuk_content_models-17.1.1 app/models/user.rb
govuk_content_models-17.1.0 app/models/user.rb
govuk_content_models-17.0.0 app/models/user.rb
govuk_content_models-16.2.0 app/models/user.rb
govuk_content_models-16.1.1 app/models/user.rb
govuk_content_models-16.1.0 app/models/user.rb
govuk_content_models-16.0.0 app/models/user.rb