Class: Admin::UsersController

Inherits:
AdminController
  • Object
show all
Includes:
Authentication, ToggleableEntity
Defined in:
app/controllers/admin/users_controller.rb

Instance Method Summary collapse

Methods included from ToggleableEntity

#toggle

Methods included from Authentication

#create_token_for_user, #deactivate_token, #pop_token, #redirect_authenticated_user

Instance Method Details

#authenticateObject

post /admin/users/:id/authenticate



57
58
59
60
61
62
63
64
65
66
# File 'app/controllers/admin/users_controller.rb', line 57

def authenticate
  cookies['pt'] = {
    value: cookies['token'],
    expires: 1.year.from_now,
    domain: :all,
    httponly: true
  }
  create_token_for_user(@entity)
  redirect_to my_path
end

#codesObject

get /admin/users/:id/codes



24
25
26
# File 'app/controllers/admin/users_controller.rb', line 24

def codes
  @collection = Code.owned_by(@entity).page_for_administration(current_page)
end

#grant_privilegeObject

put /admin/users/:id/privileges/:privilege_id



33
34
35
36
37
# File 'app/controllers/admin/users_controller.rb', line 33

def grant_privilege
  @privilege.grant(@entity, params[:region_id])

  render json: { data: { user_privilege_ids: @entity.user_privilege_ids } }
end

#indexObject

get /admin/users



9
10
11
12
# File 'app/controllers/admin/users_controller.rb', line 9

def index
  @search     = param_from_request(:q)
  @collection = User.page_for_administration current_page, @search
end

#privilegesObject

get /admin/users/:id/privileges



29
30
# File 'app/controllers/admin/users_controller.rb', line 29

def privileges
end

#revoke_privilegeObject

delete /admin/users/:id/privileges/:privilege_id



40
41
42
43
44
# File 'app/controllers/admin/users_controller.rb', line 40

def revoke_privilege
  @privilege.revoke(@entity, params[:region_id])

  render json: { data: { user_privilege_ids: @entity.user_privilege_ids } }
end

#searchObject

get /admin/users/search



47
48
49
50
51
52
53
54
# File 'app/controllers/admin/users_controller.rb', line 47

def search
  query = param_from_request(:q)
  if query.blank?
    @collection = []
  else
    @collection = User.search(query).order('slug asc').first(10)
  end
end

#showObject

get /admin/users/:id



15
16
# File 'app/controllers/admin/users_controller.rb', line 15

def show
end

#tokensObject

get /admin/users/:id/tokens



19
20
21
# File 'app/controllers/admin/users_controller.rb', line 19

def tokens
  @collection = Token.owned_by(@entity).page_for_administration(current_page)
end