Class: Oauth2Provider::ClientsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/oauth2_provider/clients_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#_oauth_provider_admin?

Methods included from ControllerMixin

#_oauth_provider_authenticate, #_oauth_provider_json_body, #_oauth_provider_normalize_token, #api_request, #json?, #oauth_authorized, #session_auth

Instance Method Details

#blockObject

TODO: this is not REST way



53
54
55
56
# File 'app/controllers/oauth2_provider/clients_controller.rb', line 53

def block
  @client.block!
  redirect_to oauth2_provider_engine.oauth2_provider_clients_url
end

#createObject



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

def create
  @client = Client.new(params[:client])
  @client.created_from = user_url(current_user)
  @client.uri          = @client.base_uri(request)
  @client.scope_values = Oauth2Provider.normalize_scope(params[:client][:scope].clone)

  if @client.save
    redirect_to oauth2_provider_engine.oauth2_provider_client_path( @client ), notice: "Resource was successfully created."
  else
    render "new"
  end
end

#destroyObject



47
48
49
50
# File 'app/controllers/oauth2_provider/clients_controller.rb', line 47

def destroy
  @client.destroy
  redirect_to(clients_url, notice: "Resource was successfully destroyed.")
end

#editObject



32
33
# File 'app/controllers/oauth2_provider/clients_controller.rb', line 32

def edit
end

#indexObject



8
9
# File 'app/controllers/oauth2_provider/clients_controller.rb', line 8

def index
end

#newObject



14
15
16
17
# File 'app/controllers/oauth2_provider/clients_controller.rb', line 14

def new
  @client = Client.new
  @client.scope = ["all"]
end

#showObject



11
12
# File 'app/controllers/oauth2_provider/clients_controller.rb', line 11

def show
end

#unblockObject



58
59
60
61
# File 'app/controllers/oauth2_provider/clients_controller.rb', line 58

def unblock
  @client.unblock!
  redirect_to oauth2_provider_engine.oauth2_provider_clients_url
end

#updateObject



35
36
37
38
39
40
41
42
43
44
45
# File 'app/controllers/oauth2_provider/clients_controller.rb', line 35

def update
  @client.scope = params[:client][:scope]
  @client.scope_values = Oauth2Provider.normalize_scope(params[:client][:scope].clone)

  if @client.update_attributes(params[:client])
    flash.now.notice = "Resource was successfully updated."
    render "show"
  else
    render action: "edit"
  end
end