osunyorg/admin

View on GitHub
app/views/extranet/account/edit.html.erb

Summary

Maintainability
Test Coverage
<% content_for :title, current_user %>

<%= simple_form_for current_user, url: account_path do |f| %>
  <%= f.error_notification %>
  <%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %>

  <div class="row">
    <div class="col-lg-6">
      <%= f.input :first_name %>
      <%= f.input :last_name %>
      <%= render 'admin/application/l10n/form', f: f %>
      <%= f.input :picture,
              as: :single_deletable_file,
              input_html: { accept: default_images_formats_accepted },
              preview: 200,
              resize: 1 %>
    </div>
    <div class="col-lg-6">
      <%= f.input :email %>
      <%= f.input :mobile_phone %>
    </div>
  </div>

  <h3 class="mt-5 mb-4"><%= t("devise.passwords.edit.new") %></h3>

  <div class="row">
    <div class="col-lg-6">
      <%= f.input :current_password,
                  as: :password,
                  input_html: { autocomplete: "current-password" } %>
    </div>
  </div>

  <div class="row">
    <div class="col-lg-6">
      <%= f.input :password,
                  as: :password_with_hints,
                  allow_password_uncloaking: true,
                  validators: {
                    length: Devise.password_length.first,
                    uppercase_char: true,
                    lowercase_char: true,
                    numeric_char: true,
                    special_char: Rails.application.config.allowed_special_chars
                  },
                  label: t('devise.passwords.edit.new_password'),
                  required: false,
                  input_html: { autocomplete: "new-password" } %>
    </div>
    <div class="col-lg-6">
      <%= f.input :password_confirmation,
                  as: :password_with_sync,
                  allow_password_uncloaking: true,
                  compare_with_field: :password,
                  input_html: { autocomplete: "new-password" } %>
    </div>
  </div>

  <%= submit f %>

  <% if current_user.visitor? %>
    <%# we don't want the osuny priviledged account to be able to get deleted through extranet %>
    <h3 class="mt-5 mb-4"><%= t("devise.registrations.edit.cancel_my_account") %></h3>

    <p><%= t("devise.registrations.edit.unhappy") %> <%= link_to t("devise.registrations.edit.cancel_my_account"), registration_path(current_user), data: { confirm: t("devise.registrations.edit.are_you_sure") }, method: :delete %></p>
  <% end %>

<% end %>