Commit 968e000d280f21668ee0bd67dda2eae8b4074256
1 parent
7c0e23cb
Exists in
oauth_login
Fix oauth_provider, upgrade doorkeeper to 3.0.1
-Fix undefined 'to_model' when creating a new applicationa -Upgrade doorkeeper to 3.0.1 -Change several html forms to conform with the new version Signed-off-by: Gustavo Jaruga Cruz <darksshades@gmail.com>
Showing
10 changed files
with
72 additions
and
13 deletions
Show diff stats
plugins/oauth_provider/Gemfile
plugins/oauth_provider/controllers/doorkeeper/application_controller.rb
plugins/oauth_provider/controllers/doorkeeper/applications_controller.rb
0 → 100644
... | ... | @@ -0,0 +1,54 @@ |
1 | +module Doorkeeper | |
2 | + class ApplicationsController < Doorkeeper::ApplicationController | |
3 | + layout 'doorkeeper/admin' | |
4 | + | |
5 | + before_action :authenticate_admin! | |
6 | + before_action :set_application, only: [:show, :edit, :update, :destroy] | |
7 | + | |
8 | + def index | |
9 | + @applications = Application.all | |
10 | + end | |
11 | + | |
12 | + def new | |
13 | + @application = Application.new | |
14 | + end | |
15 | + | |
16 | + def create | |
17 | + @application = Application.new(application_params) | |
18 | + if @application.save | |
19 | + flash[:notice] = I18n.t(:notice, scope: [:doorkeeper, :flash, :applications, :create]) | |
20 | + redirect_to oauth_application_url(@application) | |
21 | + else | |
22 | + render :new | |
23 | + end | |
24 | + end | |
25 | + | |
26 | + def update | |
27 | + if @application.update_attributes(application_params) | |
28 | + flash[:notice] = I18n.t(:notice, scope: [:doorkeeper, :flash, :applications, :update]) | |
29 | + redirect_to oauth_application_url(@application) | |
30 | + else | |
31 | + render :edit | |
32 | + end | |
33 | + end | |
34 | + | |
35 | + def destroy | |
36 | + flash[:notice] = I18n.t(:notice, scope: [:doorkeeper, :flash, :applications, :destroy]) if @application.destroy | |
37 | + redirect_to oauth_applications_url | |
38 | + end | |
39 | + | |
40 | + private | |
41 | + | |
42 | + def set_application | |
43 | + @application = Application.find(params[:id]) | |
44 | + end | |
45 | + | |
46 | + def application_params | |
47 | + if params.respond_to?(:permit) | |
48 | + params.require(:doorkeeper_application).permit(:name, :redirect_uri, :scopes) | |
49 | + else | |
50 | + params[:doorkeeper_application].slice(:name, :redirect_uri, :scopes) rescue nil | |
51 | + end | |
52 | + end | |
53 | + end | |
54 | +end | ... | ... |
plugins/oauth_provider/controllers/oauth_provider_authorizations_controller.rb
plugins/oauth_provider/views/doorkeeper/applications/_delete_form.html.erb
1 | 1 | <%- submit_btn_css ||= 'btn btn-link' %> |
2 | -<%= form_tag [:oauth, application] do %> | |
2 | +<%= form_tag oauth_application_path(application) do %> | |
3 | 3 | <input type="hidden" name="_method" value="delete"> |
4 | - <%= submit_tag 'Destroy', onclick: "return confirm('Are you sure?')", class: submit_btn_css %> | |
4 | + <%= submit_tag t('doorkeeper.applications.buttons.destroy'), onclick: "return confirm('#{ t('doorkeeper.applications.confirmations.destroy') }')", class: submit_btn_css %> | |
5 | 5 | <% end %> | ... | ... |
plugins/oauth_provider/views/doorkeeper/applications/_form.html.erb
1 | -<%= form_for [:oauth, application], html: {class: 'form-horizontal', role: 'form'} do |f| %> | |
1 | +<%= form_for application, url: doorkeeper_submit_path(application), html: {class: 'form-horizontal', role: 'form'} do |f| %> | |
2 | 2 | <% if application.errors.any? %> |
3 | 3 | <div class="alert alert-danger" data-alert> |
4 | 4 | <p><%= _('Whoops! Check your form for possible errors') %></p> | ... | ... |
plugins/oauth_provider/views/doorkeeper/applications/index.html.erb
... | ... | @@ -17,15 +17,15 @@ |
17 | 17 | <tbody> |
18 | 18 | <% @applications.each do |application| %> |
19 | 19 | <tr id="application_<%= application.id %>"> |
20 | - <td><%= link_to application.name, [:oauth, application] %></td> | |
20 | + <td><%= link_to application.name, oauth_application_path(application) %></td> | |
21 | 21 | <td><%= application.redirect_uri %></td> |
22 | - <td><%= link_to _('Edit'), edit_oauth_application_path(application), class: 'btn btn-link' %></td> | |
22 | + <td><%= link_to t('doorkeeper.applications.buttons.edit'), edit_oauth_application_path(application), class: 'btn btn-link' %></td> | |
23 | 23 | <td><%= render 'delete_form', application: application %></td> |
24 | 24 | </tr> |
25 | 25 | <% end %> |
26 | 26 | </tbody> |
27 | 27 | </table> |
28 | -<div class="actions"> | |
28 | +<div class="actions" style="padding-top: 5px;"> | |
29 | 29 | <%= button(:back, _('Go back'), {:controller => 'oauth_provider_plugin_admin', :action => 'index'}) %> |
30 | 30 | </div> |
31 | 31 | </div> | ... | ... |
plugins/oauth_provider/views/doorkeeper/applications/show.html.erb
... | ... | @@ -20,7 +20,8 @@ |
20 | 20 | <td> |
21 | 21 | <code><%= uri %></code> |
22 | 22 | </td> |
23 | - <td> | |
23 | + <td> | |
24 | + <%= link_to t('doorkeeper.applications.buttons.authorize'), oauth_authorization_path(client_id: @application.uid, redirect_uri: uri, response_type: 'code', scope: @application.scopes), class: 'btn btn-success', target: '_blank' %> | |
24 | 25 | </td> |
25 | 26 | </tr> |
26 | 27 | <% end %> | ... | ... |
plugins/oauth_provider/views/doorkeeper/authorizations/new.html.erb
... | ... | @@ -6,16 +6,16 @@ |
6 | 6 | |
7 | 7 | <main role="main"> |
8 | 8 | <p class="h4"> |
9 | - <%= _('Authorize %s to use your account?') % "<strong class=\"text-info\">#{@pre_auth.client.name}</strong>" %> | |
9 | + <%= raw _('Authorize %s to use your account?') % "<strong class=\"text-info\">#{@pre_auth.client.name}</strong>" %> | |
10 | 10 | </p> |
11 | 11 | |
12 | - <% if @pre_auth.scopes %> | |
12 | + <% if @pre_auth.scopes.count > 0 %> | |
13 | 13 | <div id="oauth-permissions"> |
14 | 14 | <p><%= _('This application will be able to:') %></p> |
15 | 15 | |
16 | 16 | <ul class="text-info"> |
17 | 17 | <% @pre_auth.scopes.each do |scope| %> |
18 | - <li><%= OauthProviderPlugin::SCOPE_TRANSLATION[scope] %></li> | |
18 | + <li><%= t scope, scope: [:doorkeeper, :scopes] %></li> | |
19 | 19 | <% end %> |
20 | 20 | </ul> |
21 | 21 | </div> | ... | ... |
plugins/oauth_provider/views/doorkeeper/authorized_applications/index.html.erb