Commit 27d0c62fcc12f5a37d4d668619118d299451db57
Committed by
Matheus Miranda Lacerda
1 parent
cb967183
Exists in
federation_oauth_provider
Adding attribute for creating account with external login
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>
Showing
4 changed files
with
19 additions
and
6 deletions
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? | ... | ... |
plugins/oauth_client/lib/ext/environment.rb
plugins/oauth_client/models/oauth_client_plugin/config.rb
| 1 | 1 | class OauthClientPlugin::Config < ApplicationRecord |
| 2 | 2 | |
| 3 | 3 | belongs_to :environment |
| 4 | + attr_accessible :create_account_for_login, :environment_id | |
| 4 | 5 | |
| 5 | - attr_accessible :create_account_for_login | |
| 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 | |
| 6 | 14 | |
| 7 | 15 | end | ... | ... |
plugins/oauth_client/views/oauth_client_plugin_admin/index.html.erb
| 1 | 1 | <h1><%= _('Oauth Client Settings') %></h1> |
| 2 | 2 | |
| 3 | -<%= labelled_form_for("") do |f| %> | |
| 3 | +<%= labelled_form_for @config, url: { action: "update_configs" } do |f| %> | |
| 4 | 4 | <table> |
| 5 | 5 | <tr> |
| 6 | - <%= hidden_field_tag('environment[enabled_features][]', '') %> | |
| 6 | + <%= hidden_field_tag "oauth_client_config[create_account_for_login]", false %> | |
| 7 | 7 | <td><%= _('Only allow login with creation of new account') %></td> |
| 8 | - <td><%= check_box_tag "environment[enabled_features][]","" ,"" %></td> | |
| 8 | + <td><%= check_box_tag "oauth_client_config[create_account_for_login]", true, @config.create_account_for_login %></td> | |
| 9 | 9 | </tr> |
| 10 | 10 | </table> |
| 11 | 11 | ... | ... |