Class: Masks::Manage::ActorsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/masks/manage/actors_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



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/masks/manage/actors_controller.rb', line 15

def create
  actor =
    .(
      nickname: params[:nickname],
      password: params[:password]
    )

  if actor.valid?
    redirect_to manage_actor_path(actor)
  else
    flash[:errors] = actor.errors.full_messages
    redirect_to manage_actors_path
  end
end

#indexObject



11
12
13
# File 'app/controllers/masks/manage/actors_controller.rb', line 11

def index
  @pagy, @actors = pagy(actor_model.all)
end

#updateObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'app/controllers/masks/manage/actors_controller.rb', line 30

def update
  actor_model.transaction do
    if params[:add_scope]
      @actor.assign_scopes!(params[:add_scope])
      flash[:info] = "added scope \"#{params[:add_scope]}\""
    elsif params[:remove_scope]
      @actor.remove_scopes!(params[:remove_scope])
      flash[:info] = "removed scope \"#{params[:remove_scope]}\""
    elsif params[:remove_factor2]
      @actor.remove_factor2!
      flash[:info] = "removed second factor authentication"
    elsif params[:logout]
      @actor.logout!
      flash[:info] = "logged out of all devices"
    elsif password_param
      password_access.change_password(password_param, actor: @actor)

      if @actor.valid?
        flash[:info] = "password changed"
      else
        flash[:error] = "invalid password"
      end
    end

    redirect_to manage_actor_path(@actor)
  end

  @actor
end