Skip to content

Commit

Permalink
Setting module
Browse files Browse the repository at this point in the history
  • Loading branch information
picman committed Nov 27, 2024
1 parent c9d0aed commit 5739263
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion app/controllers/redmine_oauth_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def try_to_login(email, info)
elsif user.active? # Active
handle_active_user user
user.update_last_login_on!
if RedmineOauth.update_login && (info['login'] || info['unique_name'])
if RedmineOauth.update_login? && (info['login'] || info['unique_name'])
user.login = info['login'] || info['unique_name']
Rails.logger.error(user.errors.full_messages.to_sentence) unless user.save
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<% if RedmineOauth.button_icon != 'none' %>
<%= stylesheet_link_tag 'redmine_oauth', plugin: 'redmine_oauth' %>
<% if RedmineOauth.hide_login_form %>
<% if RedmineOauth.hide_login_form? %>
<%= javascript_include_tag('redmine_oauth.js', plugin: :redmine_oauth) %>
<fieldset id= "oauth-fieldset-login-form" class="oauth_collapsible oauth_collapsed">
<legend class="oauth_legend" onclick="oauth_toggle_fieldset(this)"><%= l(:button_login) %></legend>
Expand All @@ -37,7 +37,7 @@
<%= l(:oauth_login_via,
oauth: RedmineOauth.custom_name.blank? ? RedmineOauth.oauth_name : RedmineOauth.custom_name).html_safe %>
<% end %>
<% if RedmineOauth.oauth_login %>
<% if RedmineOauth.oauth_login? %>
<br>
<label for="oauth_autologin">
<%= check_box_tag 'oauth_autologin', 1, false, tabindex: 6 %>
Expand Down Expand Up @@ -69,7 +69,7 @@
}
});
<%# Hidden login form %>
<% if RedmineOauth.hide_login_form %>
<% if RedmineOauth.hide_login_form? %>
let login_form = $('div#login-form');
login_form.appendTo('#oauth-fieldset-login-form');
login_form.toggle();
Expand Down
16 changes: 8 additions & 8 deletions lib/redmine_oauth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ def button_icon
end
end

def hide_login_form
def hide_login_form?
value = Setting.plugin_redmine_oauth['hide_login_form']
value.is_a?(TrueClass) || value.is_a?(FalseClass) ? value : value.to_i.positive?
value.to_i.positive? || value == 'true'
end

def self_registration
Expand All @@ -159,19 +159,19 @@ def custom_lastname_field
end
end

def update_login
def update_login?
value = Setting.plugin_redmine_oauth['update_login']
value.is_a?(TrueClass) || value.is_a?(FalseClass) ? value : value.to_i.positive?
value.to_i.positive? || value == 'true'
end

def oauth_logout
def oauth_logout?
value = Setting.plugin_redmine_oauth['oauth_logout']
value.is_a?(TrueClass) || value.is_a?(FalseClass) ? value : value.to_i.positive?
value.to_i.positive? || value == 'true'
end

def oauth_login
def oauth_login?
value = Setting.plugin_redmine_oauth['oauth_login']
value.is_a?(TrueClass) || value.is_a?(FalseClass) ? value : value.to_i.positive?
value.to_i.positive? || value == 'true'
end

def custom_logout_endpoint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module Controllers
# AccountController hooks
class AccountControllerHooks < Redmine::Hook::Listener
def controller_account_success_authentication_after(context = {})
return unless RedmineOauth.oauth_login && context[:controller].params[:oauth_autologin]
return unless RedmineOauth.oauth_login? && context[:controller].params[:oauth_autologin]

context[:controller].set_oauth_autologin_cookie
end
Expand Down
2 changes: 1 addition & 1 deletion lib/redmine_oauth/patches/account_controller_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def login

def logout
cookies.delete :oauth_autologin
return super if User.current.anonymous? || !request.post? || !RedmineOauth.oauth_logout ||
return super if User.current.anonymous? || !request.post? || !RedmineOauth.oauth_logout? ||
session[:oauth_login].blank?

session.delete :oauth_login
Expand Down

0 comments on commit 5739263

Please sign in to comment.