BananaCrystal / email-templates

This repository contains in-house email templates that serve as structure for our emails. Each template can be updated and modified to fit requirements.
MIT License
0 stars 0 forks source link

doorkeeper_applications.rb #19

Open geekelo opened 1 month ago

geekelo commented 1 month ago

FILE

ActiveAdmin.register Doorkeeper::Application do
  permit_params :name, :redirect_uri, :confidential, :scopes, :use
  includes :owner

  before_create do |application|
    application.owner = current_admin_user
  end

  menu parent: 'Configuration', label: 'OAuth Apps'

  scope('All', default: true) { |scope| scope.all }
  scope('BanaanCrystal Apps') { |scope| scope.where(owner_type: 'AdminUser') }
  scope('Store Integration Apps') { |scope| scope.where(owner_type: 'StoreIntegration') }

  preserve_default_filters!
  remove_filter :access_grants
  remove_filter :access_tokens
  remove_filter :authorized_tokens

  index do
    column :id
    column :name
    column :use
    column :redirect_uri
    column :scopes
    column :owner_type
    column 'Owner/Store' do |doorkeeper_application|
      if doorkeeper_application.owner_type == 'StoreIntegration'
        StoreIntegration.find(doorkeeper_application.owner.id).store.name
      else
        doorkeeper_application.owner
      end
    end
    column :updated_at
    actions
  end

  form do |f|
    f.inputs do
      f.input :name
      f.input :use
      f.input :redirect_uri
      f.input :confidential
      f.input :scopes
    end
    f.actions
  end
end
geekelo commented 1 month ago

This code registers a Doorkeeper::Application model with ActiveAdmin, which is a framework for creating administration interfaces in Ruby on Rails applications. The Doorkeeper::Application model is part of the Doorkeeper gem, which is used to manage OAuth 2.0 authorization in Rails applications.

Here's a breakdown of what each section of the code does:

1. Basic Configuration

2. Callbacks

3. Menu Configuration

4. Scopes

5. Filters

6. Index Page Configuration

7. Form Configuration

Summary

This configuration provides an admin interface to manage OAuth applications within your system, allowing admins to create, view, update, and delete OAuth applications, as well as view details like their owners, scopes, and redirect URIs. The customization of scopes, filters, and forms makes the admin interface more intuitive and aligned with your specific application's needs.