Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed settings syntax to make the plugin compatible with Redmine 3.4.x #48

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/controllers/redmine_oauth_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class RedmineOauthController < AccountController
include Helpers::MailHelper
include Helpers::Checker
def oauth_google
if Setting.plugin_redmine_omniauth_google[:oauth_authentification]
if Setting.plugin_redmine_omniauth_google['oauth_authentification']
session[:back_url] = params[:back_url]
redirect_to oauth_client.auth_code.authorize_url(:redirect_uri => oauth_google_callback_url, :scope => scopes)
else
Expand All @@ -18,7 +18,7 @@ def oauth_google_callback
flash[:error] = l(:notice_access_denied)
redirect_to signin_path
else
token = oauth_client.auth_code.get_token(params[:code], :redirect_uri => oauth_google_callback_url)
token = oauth_client.auth_code.get_token(params['code'], :redirect_uri => oauth_google_callback_url)
result = token.get('https://www.googleapis.com/oauth2/v1/userinfo')
info = JSON.parse(result.body)
if info && info["verified_email"]
Expand Down Expand Up @@ -83,7 +83,7 @@ def try_to_login info
end

def oauth_client
@client ||= OAuth2::Client.new(settings[:client_id], settings[:client_secret],
@client ||= OAuth2::Client.new(settings['client_id'], settings['client_secret'],
:site => 'https://accounts.google.com',
:authorize_url => '/o/oauth2/auth',
:token_url => '/o/oauth2/token')
Expand Down
2 changes: 1 addition & 1 deletion app/views/hooks/_view_account_login_bottom.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<%= stylesheet_link_tag 'buttons', :plugin => 'redmine_omniauth_google' %>

<% if Setting.plugin_redmine_omniauth_google[:oauth_authentification] %>
<% if Setting.plugin_redmine_omniauth_google['oauth_authentification'] %>
<%= link_to oauth_google_path(:back_url => back_url) do %>
<%= button_tag :class => 'button-login' do %>
<%= image_tag('/plugin_assets/redmine_omniauth_google/images/google_login_icon.png', :class => 'button-login-icon', :alt => l(:login_via_google)) %>
Expand Down
8 changes: 4 additions & 4 deletions app/views/settings/_google_settings.html.erb
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<p>
<label>Client ID:</label>
<%= text_field_tag 'settings[client_id]', @settings[:client_id] %>
<%= text_field_tag 'settings[client_id]', @settings['client_id'] %>
</p>
<p>
<label>Client Secret:</label>
<%= text_field_tag 'settings[client_secret]', @settings[:client_secret] %>
<%= text_field_tag 'settings[client_secret]', @settings['client_secret'] %>
</p>
<p>
<label>Available domains</label>
<%= text_area_tag "settings[allowed_domains]", @settings[:allowed_domains], :rows => 5 %>
<%= text_area_tag "settings[allowed_domains]", @settings['allowed_domains'], :rows => 5 %>
</p>
<p>
<label>Oauth authentification:</label>
<%= check_box_tag "settings[oauth_authentification]", true, @settings[:oauth_authentification] %>
<%= check_box_tag "settings[oauth_authentification]", true, @settings['oauth_authentification'] %>
</p>
4 changes: 2 additions & 2 deletions lib/helpers/checker.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module Helpers
module Checker
def allowed_domain_for? email
allowed_domains = Setting.plugin_redmine_omniauth_google[:allowed_domains]
allowed_domains = Setting.plugin_redmine_omniauth_google['allowed_domains']
return unless allowed_domains
allowed_domains = allowed_domains.split
return true if allowed_domains.empty?
allowed_domains.index(parse_email(email)[:domain])
end
end
end
end