Class: Masks::Manage::ClientsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/masks/manage/clients_controller.rb

Instance Attribute Summary

Attributes inherited from BaseController

#section

Instance Method Summary collapse

Methods inherited from BaseController

section

Methods included from Controller

#current_access, #current_actor, #current_mask, #masked_session

Instance Method Details

#createObject



20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/masks/manage/clients_controller.rb', line 20

def create
  client =
    Masks.configuration.model(:openid_client).new(name: params[:name])

  if client.save
    redirect_to manage_client_path(client)
  else
    flash[:errors] = client.errors.full_messages

    redirect_to manage_clients_path
  end
end

#destroyObject



52
53
54
55
56
57
58
# File 'app/controllers/masks/manage/clients_controller.rb', line 52

def destroy
  @client.destroy

  flash[:destroyed] = @client.name

  redirect_to manage_clients_path
end

#indexObject



15
16
17
18
# File 'app/controllers/masks/manage/clients_controller.rb', line 15

def index
  @pagy, @clients =
    pagy(Masks::Rails::OpenID::Client.all.order(created_at: :desc))
end

#updateObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/controllers/masks/manage/clients_controller.rb', line 33

def update
  Masks
    .configuration
    .model(:openid_client)
    .transaction do
      if params[:add_scope]
        @client.assign_scopes!(params[:add_scope])
        flash[:info] = "added scope"
      elsif params[:remove_scope]
        @client.remove_scopes!(params[:remove_scope])
        flash[:info] = "removed scope"
      else
        update_client
      end

      redirect_to manage_client_path(@client)
    end
end