Class: Archangel::Backend::UsersController

Inherits:
Archangel::BackendController show all
Includes:
Controllers::ResourcefulConcern
Defined in:
app/controllers/archangel/backend/users_controller.rb

Overview

Backend users controller

Instance Method Summary collapse

Methods included from Controllers::ResourcefulConcern

#destroy, #edit, #index, #new, #show

Methods included from Controllers::MetatagableConcern

#assign_meta_tags

Methods inherited from ApplicationController

#current_site, #render_401_error, #render_404_error, #render_error

Methods included from Controllers::PaginatableConcern

#page_num, #per_page

Methods included from Controllers::ActionableConcern

#action, #collection_action?, #member_action?

Instance Method Details

#createObject

Invite backend user

Formats

HTML, JSON

Request

POST /backend/users
POST /backend/users.json

Parameters

{
  "user": {
    "name": "First Last",
    "username": "user_name",
    "role": "editor",
    "avatar": "/uploads/file.png",
    "email": "[email protected]"
  }
}

35
36
37
38
39
40
41
# File 'app/controllers/archangel/backend/users_controller.rb', line 35

def create
  user = resource_new_content

  user.invite! user

  respond_with user, location: -> { location_after_create }
end

#updateObject

Update backend user

Formats

HTML, JSON

Params

[String] slug - the user username

Request

PATCH /backend/users/:slug
PATCH /backend/users/:slug.json
PUT   /backend/users/:slug
PUT   /backend/users/:slug.json

Parameters

{
  "user": {
    "name": "First Last",
    "username": "user_name",
    "role": "editor",
    "avatar": "/uploads/file.png",
    "email": "[email protected]"
  }
}

69
70
71
72
73
74
75
# File 'app/controllers/archangel/backend/users_controller.rb', line 69

def update
  user = resource_content

  user.update_without_password(resource_params)

  respond_with user, location: -> { location_after_update }
end