Sha256: fc9ddda746c08d6bfa5337614abedfbc4f54debf9ca1f716e84159164dd41c8a

Contents?: true

Size: 1.38 KB

Versions: 5

Compression:

Stored size: 1.38 KB

Contents

Trestle.resource(:<%= plural_name %>, model: <%= model %>, scope: Auth) do
  menu do
    group :configuration, priority: :last do
      item :<%= plural_name %>, icon: "fa fa-users"
    end
  end

  table do
    column :avatar, header: false do |administrator|
      avatar_for(administrator)
    end
    column :email, link: true
    column :otp_module, header: 'OTP'
    <%- unless devise? -%>
    column :first_name
    column :last_name
    <%- end -%>
    actions do |a|
      a.delete unless a.instance == current_user
    end
  end

  form do |administrator|

    sidebar do
      render 'qr_code' if administrator.persisted?
    end

    text_field :email

    <%- unless devise? -%>
    row do
      col(sm: 6) { text_field :first_name }
      col(sm: 6) { text_field :last_name }
    end

    <%- end -%>
    row do
      col(sm: 6) { password_field :password }
      col(sm: 6) { password_field :password_confirmation }
    end

    check_box :otp_module, label: 'Enable OTP'

  end
  <%- if devise? -%>

  update_instance do |instance, attrs|
    if attrs[:password].blank?
      attrs.delete(:password)
      attrs.delete(:password_confirmation) if attrs[:password_confirmation].blank?
    end

    instance.assign_attributes(attrs)
  end

  after_action on: :update do
    if Devise.sign_in_after_reset_password && instance == current_user
      login!(instance)
    end
  end
  <%- end -%>
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
trestle-auth-otp-0.2.2 lib/generators/trestle/auth/otp/admin/templates/admin.rb.erb
trestle-auth-otp-0.2.1 lib/generators/trestle/auth/otp/admin/templates/admin.rb.erb
trestle-auth-otp-0.2.0 lib/generators/trestle/auth/otp/admin/templates/admin.rb.erb
trestle-auth-otp-0.1.1 lib/generators/trestle/auth/otp/admin/templates/admin.rb.erb
trestle-auth-otp-0.1.0 lib/generators/trestle/auth/otp/admin/templates/admin.rb.erb