Compare View
Commits (3)
-
Signed-off-by: Sabryna Sousa <sabryna.sousa1323@gmail.com> Signed-off-by: Victor Navarro <victor.matias.navarro@gmail.com> Signed-off-by: Vitor Barbosa <vitornga15@gmail.com>
-
Signed-off-by: Gabriel Silva <gabriel93.silva@gmail.com> Signed-off-by: Victor Navarro <victor.matias.navarro@gmail.com> Signed-off-by: Vitor Barbosa <vitornga15@gmail.com>
-
Signed-off-by: Artur Bersan de Faria <artur_bersan@hotmail.com> Signed-off-by: Matheus Miranda <matheusmirandalacerda@gmail.com>
Showing
7 changed files
Show diff stats
plugins/oauth_client/controllers/oauth_client_plugin_admin_controller.rb
1 | 1 | class OauthClientPluginAdminController < AdminController |
2 | 2 | |
3 | 3 | def index |
4 | + @config = OauthClientPlugin::Config.instance | |
4 | 5 | end |
5 | 6 | |
6 | 7 | def new |
... | ... | @@ -13,6 +14,11 @@ class OauthClientPluginAdminController < AdminController |
13 | 14 | redirect_to :action => 'index' |
14 | 15 | end |
15 | 16 | |
17 | + def update_configs | |
18 | + OauthClientPlugin::Config.instance.update_attributes(params[:oauth_client_config]) | |
19 | + redirect_to :action => 'index' | |
20 | + end | |
21 | + | |
16 | 22 | def edit |
17 | 23 | @provider = params[:id] ? environment.oauth_providers.find(params[:id]) : environment.oauth_providers.new |
18 | 24 | if request.post? |
... | ... | @@ -24,4 +30,8 @@ class OauthClientPluginAdminController < AdminController |
24 | 30 | end |
25 | 31 | end |
26 | 32 | |
33 | + def edit_login_option | |
34 | + option = params['oauth_client_plugin_option'] | |
35 | + end | |
36 | + | |
27 | 37 | end | ... | ... |
plugins/oauth_client/db/migrate/20160714113820_create_oauth_client_plugin_config.rb
0 → 100644
plugins/oauth_client/lib/ext/environment.rb
plugins/oauth_client/models/oauth_client_plugin/config.rb
0 → 100644
... | ... | @@ -0,0 +1,15 @@ |
1 | +class OauthClientPlugin::Config < ApplicationRecord | |
2 | + | |
3 | + belongs_to :environment | |
4 | + attr_accessible :create_account_for_login, :environment_id | |
5 | + | |
6 | + class << self | |
7 | + def instance | |
8 | + environment = Environment.default | |
9 | + environment.oauth_client_plugin_configs || create(environment_id: environment.id) | |
10 | + end | |
11 | + | |
12 | + private :new | |
13 | + end | |
14 | + | |
15 | +end | ... | ... |
plugins/oauth_client/views/auth/_generate_providers_links.html.erb
0 → 100644
... | ... | @@ -0,0 +1,5 @@ |
1 | +<% providers.each do |provider| %> | |
2 | + <span class="provider"> | |
3 | + <%= link_to provider.image ? image_tag(provider.image.public_filename) : provider.name, "/plugin/oauth_client/#{provider.strategy}?id=#{provider.id}", :class => provider.strategy, :title => provider.name %> | |
4 | + </span> | |
5 | +<% end %> | ... | ... |
plugins/oauth_client/views/auth/_oauth_login.html.erb
1 | 1 | <div class="oauth-login"> |
2 | 2 | <% unless providers.empty? %> |
3 | - <%= _('Login with:') %> | |
3 | + <div class="providers-links"> | |
4 | + <%= _('Use my account from:') %> | |
5 | + <div> | |
6 | + <%= render :partial => 'auth/generate_providers_links', :locals => {:providers => providers} %> | |
7 | + </div> | |
8 | + <% if OauthClientPlugin::Config.instance.create_account_for_login %> | |
9 | + <%= _('Login with:') %> | |
10 | + <div> | |
11 | + <%= render :partial => 'auth/generate_providers_links', :locals => {:providers => providers} %> | |
12 | + </div> | |
13 | + <% end %> | |
14 | + </div> | |
4 | 15 | <% end %> |
5 | - <% providers.each do |provider| %> | |
6 | - <span class="provider"> | |
7 | - <%= link_to provider.image ? image_tag(provider.image.public_filename) : provider.name, "/plugin/oauth_client/#{provider.strategy}?id=#{provider.id}", :class => provider.strategy, :title => provider.name %> | |
8 | - </span> | |
9 | - <% end %> | |
10 | - | |
11 | - <span class="provider"> | |
12 | - <% unless Rails.env.production? %> | |
13 | - <%= link_to _('Developer Login'), "/plugin/oauth_client/developer", :class => 'developer' %> | |
14 | - <% end %> | |
15 | - </span> | |
16 | 16 | </div> | ... | ... |
plugins/oauth_client/views/oauth_client_plugin_admin/index.html.erb
1 | 1 | <h1><%= _('Oauth Client Settings') %></h1> |
2 | + | |
3 | +<%= labelled_form_for @config, url: { action: "update_configs" } do |f| %> | |
4 | + <table> | |
5 | + <tr> | |
6 | + <%= hidden_field_tag "oauth_client_config[create_account_for_login]", false %> | |
7 | + <td><%= _('Only allow login with creation of new account') %></td> | |
8 | + <td><%= check_box_tag "oauth_client_config[create_account_for_login]", true, @config.create_account_for_login %></td> | |
9 | + </tr> | |
10 | + </table> | |
11 | + | |
12 | + <div> | |
13 | + <%= button_bar do %> | |
14 | + <%= submit_button('save', _('Save changes')) %> | |
15 | + <%= button :back, _('Back to plugins panel'), :controller => 'plugins', :action => 'index' %> | |
16 | + <% end %> | |
17 | + </div> | |
18 | +<% end %> | |
19 | + | |
2 | 20 | <h3><%= _('Providers') %></h3> |
3 | 21 | <%= button :add, _('New'), {:action => 'new'} %> |
4 | 22 | <table> | ... | ... |