diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000000000000000000000000000000000000..4efc519ba1b78878bd2fe3cf81137c993c0c6b10 --- /dev/null +++ b/Gemfile @@ -0,0 +1 @@ +gem 'omniauth-google' \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000000000000000000000000000000000000..83f331dafcd33673ac161833d3da7ce5f4b8b610 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,7 @@ +GEM + specs: + +PLATFORMS + ruby + +DEPENDENCIES diff --git a/app/controllers/redmine_omniauth_controller.rb b/app/controllers/redmine_omniauth_controller.rb new file mode 100644 index 0000000000000000000000000000000000000000..c81e0e39a18ea49414a846a7f8679c4e6aa0165a --- /dev/null +++ b/app/controllers/redmine_omniauth_controller.rb @@ -0,0 +1,7 @@ +require 'account_controller' + +class RedmineOmniauthController < ApplicationController + def omniauth_google + AccountController.new.send(:open_id_authenticate, params[:openid_url]) + end +end diff --git a/app/helpers/redmine_omniauth_helper.rb b/app/helpers/redmine_omniauth_helper.rb new file mode 100644 index 0000000000000000000000000000000000000000..e1d24455f65bf3be7622f065738e099df26d4c73 --- /dev/null +++ b/app/helpers/redmine_omniauth_helper.rb @@ -0,0 +1,2 @@ +module RedmineOmniauthHelper +end diff --git a/app/views/hooks/_view_account_login_bottom.html.erb b/app/views/hooks/_view_account_login_bottom.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..5e569b5ea4532eca5b889287a36b54964b1d9f29 --- /dev/null +++ b/app/views/hooks/_view_account_login_bottom.html.erb @@ -0,0 +1,3 @@ +<% if Setting.openid? %> + <%= link_to image_tag('/plugin_assets/redmine_omniauth_google/images/google_login_icon.jpg'), omniauth_google_path(openid_url: 'google.com') %> +<% end %> \ No newline at end of file diff --git a/app/views/redmine_omniauth/omniauth_google.html.erb b/app/views/redmine_omniauth/omniauth_google.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..8949207c6cea1e0b02872a5ba2467607d91ff8e5 --- /dev/null +++ b/app/views/redmine_omniauth/omniauth_google.html.erb @@ -0,0 +1 @@ +<h2>RedmineOmniauthController#omniauth_google</h2> diff --git a/assets/images/google_login_icon.jpg b/assets/images/google_login_icon.jpg new file mode 100644 index 0000000000000000000000000000000000000000..1f6cb5393098569ce2ef78b3a6142050118d8fec Binary files /dev/null and b/assets/images/google_login_icon.jpg differ diff --git a/config/routes.rb b/config/routes.rb index 1803173d04b8ce4e30716a4e894f01bc8a10ced8..5a39baa3f20dbedf9980948592614395c08d4085 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,2 +1 @@ -# Plugin's routes -# See: http://guides.rubyonrails.org/routing.html +get 'omniauth_google', to: 'redmine_omniauth#omniauth_google', as: :omniauth_google \ No newline at end of file diff --git a/init.rb b/init.rb index 470481f1c8b8be00cb128a404687456e2073a60b..f451b16d517a8c01c4b017197d2693d43d816b57 100644 --- a/init.rb +++ b/init.rb @@ -1,5 +1,5 @@ require 'redmine' -require_dependency 'redmine_omniauth_google/hooks/view_account_login_bottom_hook' +require_dependency 'hooks/view_account_login_bottom_hook' Redmine::Plugin.register :redmine_omniauth_google do name 'Redmine Omniauth Google plugin' diff --git a/lib/hooks/view_account_login_bottom_hook.rb b/lib/hooks/view_account_login_bottom_hook.rb new file mode 100644 index 0000000000000000000000000000000000000000..8cd147faaebe83eb4dcee9293d31769f5927ab7d --- /dev/null +++ b/lib/hooks/view_account_login_bottom_hook.rb @@ -0,0 +1,10 @@ +module Hooks + class ViewAccountLoginBottomHook < Redmine::Hook::ViewListener + def view_account_login_bottom context = {} + context[:controller].send(:render_to_string, { + partial: "hooks/view_account_login_bottom", + locals: context + }) + end + end +end \ No newline at end of file diff --git a/test/functional/redmine_omniauth_controller_test.rb b/test/functional/redmine_omniauth_controller_test.rb new file mode 100644 index 0000000000000000000000000000000000000000..6604da30299bd188dc3b9aa76572a7d7e149c2c0 --- /dev/null +++ b/test/functional/redmine_omniauth_controller_test.rb @@ -0,0 +1,8 @@ +require File.expand_path('../../test_helper', __FILE__) + +class RedmineOmniauthControllerTest < ActionController::TestCase + # Replace this with your real tests. + def test_truth + assert true + end +end