From 9102fe841d9a5af4e274f7547763fa1ad8fa05e1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9=20=D0=9A=D0=BE?=
 =?UTF-8?q?=D0=B2=D0=B0=D0=BB=D0=B5=D0=BD=D0=BE=D0=BA?=
 <dmitry.kovalenok@twinslash.com>
Date: Thu, 8 Nov 2012 08:56:29 +0300
Subject: [PATCH] deleting files

---
 .../redmine_omniauth_controller.rb            | 73 -------------------
 .../_view_account_login_bottom.html.erb       |  1 -
 .../redmine_omniauth/omniauth_google.html.erb |  1 -
 .../redmine_oauth_controller_test.rb          |  1 -
 .../redmine_omniauth_controller_test.rb       |  8 --
 5 files changed, 84 deletions(-)
 delete mode 100644 app/controllers/redmine_omniauth_controller.rb
 delete mode 100644 app/views/hooks/redmine_omniauth_google/_view_account_login_bottom.html.erb
 delete mode 100644 app/views/redmine_omniauth/omniauth_google.html.erb
 delete mode 100644 test/functional/redmine_omniauth_controller_test.rb

diff --git a/app/controllers/redmine_omniauth_controller.rb b/app/controllers/redmine_omniauth_controller.rb
deleted file mode 100644
index 64bbca0..0000000
--- a/app/controllers/redmine_omniauth_controller.rb
+++ /dev/null
@@ -1,73 +0,0 @@
-require 'account_controller'
-require 'json'
-
-class RedmineOauthController < AccountController
-  def oauth_google
-    ds
-    redirect_to oauth_client.auth_code.authorize_url(redirect_uri: oauth_google_callback_url, scope: scopes)
-  end
-
-  def oauth_google_callback
-    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')
-    binding.pr
-    info = JSON.parse(result.body)
-    if info && info["verified_email"]
-      user = User.find_or_initialize_by_mail(info["email"])
-      if user.new_record?
-        # Self-registration off
-        redirect_to(home_url) && return unless Setting.self_registration?
-        # Create on the fly
-        user.firstname, user.lastname = info["name"].split(' ') unless info['name'].nil?
-        user.firstname ||= info[:given_name]
-        user.lastname ||= info[:family_name]
-        user.mail = info["email"]
-        login = info["email"].match(/(.+)@/) unless info["email"].nil?
-        user.login = login[1] if login
-        user.login ||= [user.firstname, user.lastname]*"."
-        user.random_password
-        user.register
-
-        case Setting.self_registration
-        when '1'
-          register_by_email_activation(user) do
-            onthefly_creation_failed(user)
-          end
-        when '3'
-          register_automatically(user) do
-            onthefly_creation_failed(user)
-          end
-        else
-          register_manually_by_administrator(user) do
-            onthefly_creation_failed(user)
-          end
-        end
-      else
-        # Existing record
-        if user.active?
-          successful_authentication(user)
-        else
-          account_pending
-        end
-      end
-    else
-      flash[:error] = l(:notice_unable_to_obtain_google_credentials)
-      redirect_to signin_path
-    end
-  end
-
-  def oauth_client
-    @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')
-  end
-
-  def settings
-    @settings ||= Setting.plugin_redmine_omniauth_google
-  end
-
-  def scopes
-    'https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile'
-  end
-end
\ No newline at end of file
diff --git a/app/views/hooks/redmine_omniauth_google/_view_account_login_bottom.html.erb b/app/views/hooks/redmine_omniauth_google/_view_account_login_bottom.html.erb
deleted file mode 100644
index eede9e0..0000000
--- a/app/views/hooks/redmine_omniauth_google/_view_account_login_bottom.html.erb
+++ /dev/null
@@ -1 +0,0 @@
-<p><%= "render with google" %></p>
\ 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
deleted file mode 100644
index 8949207..0000000
--- a/app/views/redmine_omniauth/omniauth_google.html.erb
+++ /dev/null
@@ -1 +0,0 @@
-<h2>RedmineOmniauthController#omniauth_google</h2>
diff --git a/test/functional/redmine_oauth_controller_test.rb b/test/functional/redmine_oauth_controller_test.rb
index 15690e4..ccb3fa3 100644
--- a/test/functional/redmine_oauth_controller_test.rb
+++ b/test/functional/redmine_oauth_controller_test.rb
@@ -1,5 +1,4 @@
 require File.expand_path('../../test_helper', __FILE__)
-#require File.expand_path('../../../lib/helpers/mail_helper', __FILE__)
 
 class RedmineOauthControllerTest < ActionController::TestCase
   include Helpers::MailHelper
diff --git a/test/functional/redmine_omniauth_controller_test.rb b/test/functional/redmine_omniauth_controller_test.rb
deleted file mode 100644
index 6604da3..0000000
--- a/test/functional/redmine_omniauth_controller_test.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require File.expand_path('../../test_helper', __FILE__)
-
-class RedmineOmniauthControllerTest < ActionController::TestCase
-  # Replace this with your real tests.
-  def test_truth
-    assert true
-  end
-end
-- 
GitLab