Commit b49b7bc1 authored by Nick Thomas's avatar Nick Thomas

Warn users when their keys are invalid

parent b0f982fb
module FormHelper module FormHelper
def form_errors(model) def form_errors(model, headline = 'The form contains the following')
return unless model.errors.any? return unless model.errors.any?
pluralized = 'error'.pluralize(model.errors.count) pluralized = 'error'.pluralize(model.errors.count)
headline = "The form contains the following #{pluralized}:"
headline = headline + ' ' + pluralized + ':'
content_tag(:div, class: 'alert alert-danger', id: 'error_explanation') do content_tag(:div, class: 'alert alert-danger', id: 'error_explanation') do
content_tag(:h4, headline) << content_tag(:h4, headline) <<
......
%li.key-list-item %li.key-list-item
.pull-left.append-right-10 .pull-left.append-right-10
= icon 'key', class: "settings-list-icon hidden-xs" - if key.valid?
= icon 'key', class: 'settings-list-icon hidden-xs'
- else
= icon 'exclamation-triangle', class: 'settings-list-icon hidden-xs',
title: 'The key is disabled because it is invalid'
.key-list-item-info .key-list-item-info
= link_to path_to_key(key, is_admin), class: "title" do = link_to path_to_key(key, is_admin), class: "title" do
= key.title = key.title
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
%strong= @key.last_used_at.try(:to_s, :medium) || 'N/A' %strong= @key.last_used_at.try(:to_s, :medium) || 'N/A'
.col-md-8 .col-md-8
= form_errors(@key, 'The key has the following') unless @key.valid?
%p %p
%span.light Fingerprint: %span.light Fingerprint:
%code.key-fingerprint= @key.fingerprint %code.key-fingerprint= @key.fingerprint
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment