Sha256: 68ca262260dd14397b3c04f921dbf3374bfe2b5c7021d6743c3d9ee72f8b18f3

Contents?: true

Size: 1.56 KB

Versions: 2

Compression:

Stored size: 1.56 KB

Contents

format do
  view :verify_url, cache: :never, denial: :blank do
    raise Error::PermissionDenied unless card.ok?(:create) || card.action

    token_url :verify_and_activate, anonymous: true
  end

  view :reset_password_url, denial: :blank do
    raise Error::PermissionDenied unless card.password_card.ok? :update

    token_url :reset_password
  end

  view :token_expiry, denial: :blank do
    "(#{token_expiry_sentence}"
  end

  view :token_days, denial: :blank do
    Card.config.token_expiry / 1.day
  end

  # DEPRECATED
  view :verify_days, :token_days
  view :reset_password_days, :token_days

  def token_url trigger, extra_payload={}
    card_url path(action: :update,
                  card: { trigger: trigger },
                  token: new_token(extra_payload))
  end

  def token_expiry_sentence
    "Link will expire in #{render_token_days} days"
  end

  def new_token extra_payload
    Auth::Token.encode card.accounted_id, extra_payload
  end
end

format :html do
  view :core do
    [account_field_nest(:email, "email"),
     account_field_nest(:password, "password")]
  end

  def account_field_nest field, title
    field_nest field, title: title, view: :labeled
    # edit: :inline, hide: [:help_link, :board_link]
  end

  before :content_formgroups do
    voo.edit_structure = [[:email, title: "email"],
                          [:password, title: "password"]]
  end

  view :token_expiry do
    "<p><em>#{token_expiry_sentence}</em></p>"
  end
end

format :email_html do
  def mail context, fields
    super context, fields.reverse_merge(to: card.email)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
card-mod-account-0.18.1 set/right/account/views.rb
card-mod-account-0.18.0 set/right/account/views.rb