Class: Landable::Api::AccessTokensController
Constant Summary
Landable::ApiController::API_MEDIA_REGEX
Instance Method Summary
collapse
#api_media
Instance Method Details
#create ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
|
# File 'app/controllers/landable/api/access_tokens_controller.rb', line 12
def create
ident = AuthenticationService.call(asset_token_params[:username], asset_token_params[:password])
author = RegistrationService.call(ident)
permissions = determine_permissions(ident[:groups])
respond_with AccessToken.create!(author: author, permissions: permissions), status: :created
rescue Landable::AuthenticationFailedError
head :unauthorized
end
|
#destroy ⇒ Object
31
32
33
34
35
36
37
|
# File 'app/controllers/landable/api/access_tokens_controller.rb', line 31
def destroy
token = find_own_access_token
token.destroy!
head :no_content
rescue ActiveRecord::RecordNotFound
head :unauthorized
end
|
#show ⇒ Object
8
9
10
|
# File 'app/controllers/landable/api/access_tokens_controller.rb', line 8
def show
respond_with find_own_access_token
end
|
#update ⇒ Object
24
25
26
27
28
29
|
# File 'app/controllers/landable/api/access_tokens_controller.rb', line 24
def update
token = find_own_access_token
token.refresh!
respond_with token
end
|