From 6fec3261a4cb78ab6dc339a6c715987b13b8d21d Mon Sep 17 00:00:00 2001 From: kenzo-tanaka Date: Sun, 18 Sep 2022 21:51:38 +0900 Subject: [PATCH 01/39] Add klass names to template --- lib/generators/any_login/templates/any_login.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/generators/any_login/templates/any_login.rb b/lib/generators/any_login/templates/any_login.rb index 7a5c397..6514c16 100644 --- a/lib/generators/any_login/templates/any_login.rb +++ b/lib/generators/any_login/templates/any_login.rb @@ -8,6 +8,9 @@ # # Account, User, Person, etc # config.klass_name = 'User' + # # ['User', 'Staff', etc] + # config.klass_names = ['User'] + # # .all, .active, .admins, .groped_collection, etc ... need to return an array (or hash with arrays) of users # config.collection_method = :all From a86b19470032659c7ee0da2ff04b5cfe8e585086 Mon Sep 17 00:00:00 2001 From: kenzo-tanaka Date: Sun, 18 Sep 2022 21:53:50 +0900 Subject: [PATCH 02/39] Add default value of klass names --- lib/any_login.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/any_login.rb b/lib/any_login.rb index 0210d7d..868229a 100755 --- a/lib/any_login.rb +++ b/lib/any_login.rb @@ -24,6 +24,10 @@ module Provider mattr_accessor :klass_name @@klass_name = 'User' + # # ['User', 'Staff', etc] + mattr_accessor :klass_names + @@klass_names = ['User'] + # Sign-in Method mattr_accessor :sign_in @@sign_in = nil From 4ff39eb0602acaafd469e79d7e305e79cd203ac1 Mon Sep 17 00:00:00 2001 From: kenzo-tanaka Date: Sun, 18 Sep 2022 21:56:24 +0900 Subject: [PATCH 03/39] Get new params as for switching login class --- app/controllers/any_login/application_controller.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/controllers/any_login/application_controller.rb b/app/controllers/any_login/application_controller.rb index 385b19d..48b5df3 100755 --- a/app/controllers/any_login/application_controller.rb +++ b/app/controllers/any_login/application_controller.rb @@ -41,6 +41,10 @@ def user_id params[:back_to_previous_id].presence || params[:selected_id].presence || params[:id] end + def klass + params[:as].constantize + end + def previous cookies[AnyLogin.cookie_name] ||= "" end From ba8ed2c82052f9e7d3f04a1a6f2790a000821a93 Mon Sep 17 00:00:00 2001 From: kenzo-tanaka Date: Sun, 18 Sep 2022 22:01:44 +0900 Subject: [PATCH 04/39] Add klasses method to any_login.rb --- lib/any_login.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/any_login.rb b/lib/any_login.rb index 868229a..a34b02d 100755 --- a/lib/any_login.rb +++ b/lib/any_login.rb @@ -100,6 +100,10 @@ def self.klass @@klass = AnyLogin.klass_name.constantize end + def self.klasses + @@klasses = AnyLogin.klass_names.map(&:constantize) + end + def self.cookie_name module_parent_name = if Rails::VERSION::MAJOR >= 6 Rails.application.class.module_parent_name From 885e07eab038e293481fb5874097e7deff5d5f5f Mon Sep 17 00:00:00 2001 From: kenzo-tanaka Date: Sun, 18 Sep 2022 22:05:02 +0900 Subject: [PATCH 05/39] Display login forms --- app/views/any_login/_any_login.html.erb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/views/any_login/_any_login.html.erb b/app/views/any_login/_any_login.html.erb index bc3c031..2815474 100755 --- a/app/views/any_login/_any_login.html.erb +++ b/app/views/any_login/_any_login.html.erb @@ -1,6 +1,13 @@ + +