diff --git a/README.md b/README.md
index 10cbe01..3d7cc42 100755
--- a/README.md
+++ b/README.md
@@ -89,8 +89,8 @@ In `app/lib/anylogin_omniauth.rb`
```
module AnyloginOmniauth
module Controller
- def self.any_login_current_user_method
- @@any_login_current_user_method ||= "current_#{AnyLogin.klass.to_s.parameterize.underscore}".to_sym
+ def self.any_login_current_user_method(klass)
+ @@any_login_current_user_method ||= "current_#{klass.to_s.parameterize.underscore}".to_sym
end
def any_login_sign_in
@@ -114,7 +114,7 @@ It will create the initializer file `config/initializers/any_login.rb`.
### Options
- **enabled** - enable or disable gem (by default this gem is enabled only in development mode).
-- **klass_name** - class name for "User" object. Defaults to `User`.
+- **klass_name** - class name for "User" object. Defaults to `User`. An array of class names is also supported.
- **collection_method** - method which returns collection of users. Sample:
`.all`, `.active`, `.admins`, `.groupped_users`. Value is a simple.
Defaults to `:all`.
@@ -130,7 +130,6 @@ It will create the initializer file `config/initializers/any_login.rb`.
- **position** - position of AnyLogin box on page. Possible values: `top_left`,
`top_right`, `bottom_left`, `bottom_right`. Default: `bottom_left`.
- **login_button_label** - login button label.
-- **select_prompt** - select prompt message.
- **auto_show** - automatically show AnyLogin box.
- **http_basic_authentication_enabled** - Enable HTTP_BASIC authentication.
- **http_basic_authentication_user_name** - HTTP_BASIC authentication user name.
diff --git a/app/assets/javascripts/any_login/application.js b/app/assets/javascripts/any_login/application.js
index fa8edc5..a8ab42b 100644
--- a/app/assets/javascripts/any_login/application.js
+++ b/app/assets/javascripts/any_login/application.js
@@ -1,21 +1,13 @@
-function submitOnChange() {
- document.getElementById('any_login_form').submit();
-}
-
-function elementExists(element) {
- return typeof (element) != 'undefined' && element != null;
-}
-
-function addChangeListenerTo(elementId) {
- let element = document.getElementById(elementId);
- if (elementExists(element)) {
- element.addEventListener("change", submitOnChange);
- }
-}
-
function setupAnyLoginHandlers() {
- addChangeListenerTo("back_to_previous_id");
- addChangeListenerTo("selected_id");
+ const forms = document.querySelectorAll('.any_login_form');
+ forms.forEach(form => {
+ const selects = form.querySelectorAll('select');
+ selects.forEach(select => {
+ select.addEventListener('change', () => {
+ form.submit();
+ })
+ })
+ })
}
['DOMContentLoaded', 'turbolinks:load', 'turbo:load'].forEach(function(e) {
diff --git a/app/assets/stylesheets/any_login/application.css b/app/assets/stylesheets/any_login/application.css
index 4e9c31b..b29c3f8 100644
--- a/app/assets/stylesheets/any_login/application.css
+++ b/app/assets/stylesheets/any_login/application.css
@@ -66,6 +66,7 @@
cursor: pointer;
vertical-align: middle;
fill: #fff;
+ margin: 5px;
}
#any_login:hover {
@@ -77,20 +78,24 @@
color: yellow;
}
-#any_login #any_login_id_input {
+#any_login .any_login_id_input {
width: 30px;
}
-#any_login span#current_user_information {
+#any_login span.current_user_information {
display: inline;
}
-#any_login span#current_user_information span {
+#any_login span.current_user_information span {
display: inline;
}
-#any_login span#anylogin_back_to_user {
+#any_login span.anylogin_back_to_user {
padding-left: 15px;
color: cyan;
display: inline;
}
+
+.any_login_form_toggle_label {
+ display: inline-block;
+}
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
diff --git a/app/views/any_login/_any_login.html.erb b/app/views/any_login/_any_login.html.erb
index bc3c031..50b5e51 100755
--- a/app/views/any_login/_any_login.html.erb
+++ b/app/views/any_login/_any_login.html.erb
@@ -2,18 +2,21 @@
- <%= form_tag any_login.sign_in_path, :method => :post, :id => 'any_login_form' do %>
-
- >
-
- <%= any_login_select %>
- or by
- <%= any_login_id_input %>
- <%= any_login_submit %>
- <%= current_user_information %>
- <%= any_login_previous_select %>
-
- <% end %>
+
+ >
+
+
+ <% AnyLogin.klasses.each do |klass| %>
+ <%= form_tag any_login.sign_in_path(as: klass.to_s), :method => :post, :class => 'any_login_form' do %>
+ <%= any_login_select(klass) %>
+ or by
+ <%= any_login_id_input %>
+ <%= any_login_submit %>
+ <%= current_user_information(klass) %>
+ <%= any_login_previous_select(klass) %>
+ <% end %>
+ <% end %>
+
diff --git a/app/views/any_login/svg/_user.html.erb b/app/views/any_login/svg/_user.html.erb
index 1a07606..0db9b89 100644
--- a/app/views/any_login/svg/_user.html.erb
+++ b/app/views/any_login/svg/_user.html.erb
@@ -1,6 +1,5 @@