any_login_multiple 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -5
- data/app/controllers/{easy_login → any_login_multiple}/application_controller.rb +2 -2
- data/app/views/any_login_multiple/_any_login_multiple.html.erb +65 -0
- data/config/routes.rb +2 -2
- data/lib/any_login_multiple.rb +16 -0
- data/lib/any_login_multiple/engine.rb +11 -0
- data/lib/any_login_multiple/helpers.rb +9 -0
- data/lib/any_login_multiple/routes.rb +7 -0
- data/lib/any_login_multiple/version.rb +3 -0
- metadata +14 -15
- data/app/helpers/easy_login/application_helper.rb +0 -7
- data/app/views/easy_login/_easy_login.html.erb +0 -65
- data/lib/easy_login.rb +0 -16
- data/lib/easy_login/engine.rb +0 -11
- data/lib/easy_login/helpers.rb +0 -9
- data/lib/easy_login/routes.rb +0 -7
- data/lib/easy_login/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e84bdaed139698dc7af4dea06cd4b854c67b05b3658daa997f5f070049234bc0
|
4
|
+
data.tar.gz: 2911e27a1caac2c4626e94e5a3abf2d76994556eb06e0f504b309a706eed3560
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25f50f917a32e1eff194617cf223d2e8313067213dbffe16193b218a5b49c079da59b6f506f313d40aa8c603f7fcfc820b255bbd41e3a019261cc8d7bdf3d2d9
|
7
|
+
data.tar.gz: ec4b7641c825feda970270d72264d53221a6f668cb63f46628dad57b6e1f767721f5b33ec0d97572b898a80c88d95d84a8be2da44a09194a6744c9d8568364c9
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# AnyLoginMultiple
|
2
2
|
|
3
3
|
This gem is inspired by [any_login](https://github.com/igorkasyanchuk/any_login).
|
4
4
|
This gem supports multiple model support.
|
@@ -12,7 +12,7 @@ Add this line to your application's Gemfile:
|
|
12
12
|
|
13
13
|
```ruby
|
14
14
|
group :development do
|
15
|
-
gem '
|
15
|
+
gem 'any_login_multiple'
|
16
16
|
end
|
17
17
|
```
|
18
18
|
|
@@ -21,10 +21,10 @@ And then execute:
|
|
21
21
|
$ bundle install
|
22
22
|
```
|
23
23
|
|
24
|
-
Add `config/initializers/
|
24
|
+
Add `config/initializers/any_login_multiple.rb` and set `klass_names`:
|
25
25
|
|
26
26
|
```rb
|
27
|
-
|
27
|
+
AnyLoginMultiple.klass_names = ['User', 'Staff']
|
28
28
|
```
|
29
29
|
|
30
30
|
## Usage
|
@@ -32,7 +32,7 @@ EasyLogin.klass_names = ['User', 'Staff']
|
|
32
32
|
Add this line to `application.html.erb`:
|
33
33
|
|
34
34
|
```erb
|
35
|
-
<%=
|
35
|
+
<%= any_login_multiple_here if Rails.env.development? %>
|
36
36
|
```
|
37
37
|
|
38
38
|
## License
|
@@ -0,0 +1,65 @@
|
|
1
|
+
<div class="any-login-multiple-wrapper" style="opacity: 70%;">
|
2
|
+
<a class="any-login-multiple-trigger">Display Form</a>
|
3
|
+
<div class="any-login-multiple-forms-container" style='display: none;'>
|
4
|
+
<% AnyLoginMultiple.klass_names.each do |klass_name| %>
|
5
|
+
<%= form_with url: any_login_multiple.sign_in_path(as: klass_name), class: 'any-login-multiple-form', method: :post do |form| %>
|
6
|
+
<label>
|
7
|
+
<%= klass_name %>
|
8
|
+
</label>
|
9
|
+
<%= form.select :id, klass_name.constantize.pluck(:email, :id) %>
|
10
|
+
<%= form.submit 'Submit' %>
|
11
|
+
<% end %>
|
12
|
+
<% end %>
|
13
|
+
</div>
|
14
|
+
</div>
|
15
|
+
|
16
|
+
<style>
|
17
|
+
.any-login-multiple-wrapper {
|
18
|
+
position: fixed;
|
19
|
+
bottom: 0;
|
20
|
+
left: 0;
|
21
|
+
background: #5c4383;
|
22
|
+
color: white;
|
23
|
+
z-index: 100;
|
24
|
+
padding: 5px 10px;
|
25
|
+
}
|
26
|
+
.any-login-multiple-trigger {
|
27
|
+
color: white;
|
28
|
+
cursor: pointer;
|
29
|
+
}
|
30
|
+
</style>
|
31
|
+
|
32
|
+
<script type="text/javascript" charset="utf-8">
|
33
|
+
window.AnyLoginMultiple = window.AnyLoginMultiple || {};
|
34
|
+
|
35
|
+
window.AnyLoginMultiple.on_select_change = () => {
|
36
|
+
const anyLoginMultipleForm = document.querySelectorAll('.any-login-multiple-form');
|
37
|
+
anyLoginMultipleForm.forEach(form => {
|
38
|
+
const select = form.querySelector('select')
|
39
|
+
select.addEventListener('change', () => {
|
40
|
+
form.submit();
|
41
|
+
})
|
42
|
+
})
|
43
|
+
}
|
44
|
+
|
45
|
+
window.AnyLoginMultiple.on_select_change();
|
46
|
+
|
47
|
+
window.AnyLoginMultiple.display_forms = () => {
|
48
|
+
const trigger = document.querySelector('.any-login-multiple-trigger');
|
49
|
+
const wrapper = document.querySelector('.any-login-multiple-wrapper')
|
50
|
+
|
51
|
+
trigger.addEventListener('click', () => {
|
52
|
+
const formBox = document.querySelector('.any-login-multiple-forms-container');
|
53
|
+
if (formBox.style.display == 'none') {
|
54
|
+
formBox.style.display = 'block'
|
55
|
+
wrapper.style.opacity = '100%'
|
56
|
+
trigger.textContent = 'Hide Form'
|
57
|
+
} else {
|
58
|
+
formBox.style.display = 'none'
|
59
|
+
wrapper.style.opacity = '70%'
|
60
|
+
trigger.textContent = 'Display Form'
|
61
|
+
}
|
62
|
+
})
|
63
|
+
}
|
64
|
+
window.AnyLoginMultiple.display_forms();
|
65
|
+
</script>
|
data/config/routes.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
post '/
|
1
|
+
AnyLoginMultiple::Engine.routes.draw do
|
2
|
+
post '/any_login_multiple/sign_in', to: 'application#any_login_multiple', as: :sign_in
|
3
3
|
end
|
4
4
|
|
5
5
|
Rails.application.routes.draw do
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "any_login_multiple/version"
|
2
|
+
require "any_login_multiple/engine"
|
3
|
+
|
4
|
+
module AnyLoginMultiple
|
5
|
+
extend ActiveSupport::Autoload
|
6
|
+
autoload :Helpers
|
7
|
+
|
8
|
+
mattr_accessor :klass_names
|
9
|
+
@@klass_names = ['User']
|
10
|
+
|
11
|
+
def self.klasses
|
12
|
+
@@klasses = AnyLoginMultiple.klass_names.map(&:constantize)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
require 'any_login_multiple/routes'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: any_login_multiple
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kenzo-tanaka
|
@@ -44,7 +44,7 @@ dependencies:
|
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: 6.1.4.1
|
47
|
-
description: Easy login with devise, multiple model
|
47
|
+
description: Easy way to login with devise, multiple model
|
48
48
|
email:
|
49
49
|
- kenzou.kenzou104809@gmail.com
|
50
50
|
executables: []
|
@@ -54,22 +54,21 @@ files:
|
|
54
54
|
- MIT-LICENSE
|
55
55
|
- README.md
|
56
56
|
- Rakefile
|
57
|
-
- app/controllers/
|
58
|
-
- app/
|
59
|
-
- app/views/easy_login/_easy_login.html.erb
|
57
|
+
- app/controllers/any_login_multiple/application_controller.rb
|
58
|
+
- app/views/any_login_multiple/_any_login_multiple.html.erb
|
60
59
|
- config/routes.rb
|
61
|
-
- lib/
|
62
|
-
- lib/
|
63
|
-
- lib/
|
64
|
-
- lib/
|
65
|
-
- lib/
|
66
|
-
homepage: https://github.com/kenzo-tanaka/
|
60
|
+
- lib/any_login_multiple.rb
|
61
|
+
- lib/any_login_multiple/engine.rb
|
62
|
+
- lib/any_login_multiple/helpers.rb
|
63
|
+
- lib/any_login_multiple/routes.rb
|
64
|
+
- lib/any_login_multiple/version.rb
|
65
|
+
homepage: https://github.com/kenzo-tanaka/any_login_multiple
|
67
66
|
licenses:
|
68
67
|
- MIT
|
69
68
|
metadata:
|
70
|
-
homepage_uri: https://github.com/kenzo-tanaka/
|
71
|
-
source_code_uri: https://github.com/kenzo-tanaka/
|
72
|
-
changelog_uri: https://github.com/kenzo-tanaka/
|
69
|
+
homepage_uri: https://github.com/kenzo-tanaka/any_login_multiple
|
70
|
+
source_code_uri: https://github.com/kenzo-tanaka/any_login_multiple
|
71
|
+
changelog_uri: https://github.com/kenzo-tanaka/any_login_multiple/blob/main/CHANGELOG.md
|
73
72
|
post_install_message:
|
74
73
|
rdoc_options: []
|
75
74
|
require_paths:
|
@@ -88,5 +87,5 @@ requirements: []
|
|
88
87
|
rubygems_version: 3.1.6
|
89
88
|
signing_key:
|
90
89
|
specification_version: 4
|
91
|
-
summary: Easy login with devise, multiple model
|
90
|
+
summary: Easy way to login with devise, multiple model
|
92
91
|
test_files: []
|
@@ -1,65 +0,0 @@
|
|
1
|
-
<div class="easy-login-wrapper" style="opacity: 70%;">
|
2
|
-
<a class="easy-login-trigger">Display Form</a>
|
3
|
-
<div class="easy-login-forms-container" style='display: none;'>
|
4
|
-
<% EasyLogin.klass_names.each do |klass_name| %>
|
5
|
-
<%= form_with url: easy_login.sign_in_path(as: klass_name), class: 'easy-login-form', method: :post do |form| %>
|
6
|
-
<label>
|
7
|
-
<%= klass_name %>
|
8
|
-
</label>
|
9
|
-
<%= form.select :id, klass_name.constantize.pluck(:email, :id) %>
|
10
|
-
<%= form.submit 'Submit' %>
|
11
|
-
<% end %>
|
12
|
-
<% end %>
|
13
|
-
</div>
|
14
|
-
</div>
|
15
|
-
|
16
|
-
<style>
|
17
|
-
.easy-login-wrapper {
|
18
|
-
position: fixed;
|
19
|
-
bottom: 0;
|
20
|
-
left: 0;
|
21
|
-
background: #5c4383;
|
22
|
-
color: white;
|
23
|
-
z-index: 100;
|
24
|
-
padding: 5px 10px;
|
25
|
-
}
|
26
|
-
.easy-login-trigger {
|
27
|
-
color: white;
|
28
|
-
cursor: pointer;
|
29
|
-
}
|
30
|
-
</style>
|
31
|
-
|
32
|
-
<script type="text/javascript" charset="utf-8">
|
33
|
-
window.EasyLogin = window.EasyLogin || {};
|
34
|
-
|
35
|
-
window.EasyLogin.on_select_change = () => {
|
36
|
-
const easyLoginForm = document.querySelectorAll('.easy-login-form');
|
37
|
-
easyLoginForm.forEach(form => {
|
38
|
-
const select = form.querySelector('select')
|
39
|
-
select.addEventListener('change', () => {
|
40
|
-
form.submit();
|
41
|
-
})
|
42
|
-
})
|
43
|
-
}
|
44
|
-
|
45
|
-
window.EasyLogin.on_select_change();
|
46
|
-
|
47
|
-
window.EasyLogin.display_forms = () => {
|
48
|
-
const trigger = document.querySelector('.easy-login-trigger');
|
49
|
-
const wrapper = document.querySelector('.easy-login-wrapper')
|
50
|
-
|
51
|
-
trigger.addEventListener('click', () => {
|
52
|
-
const formBox = document.querySelector('.easy-login-forms-container');
|
53
|
-
if (formBox.style.display == 'none') {
|
54
|
-
formBox.style.display = 'block'
|
55
|
-
wrapper.style.opacity = '100%'
|
56
|
-
trigger.textContent = 'Hide Form'
|
57
|
-
} else {
|
58
|
-
formBox.style.display = 'none'
|
59
|
-
wrapper.style.opacity = '70%'
|
60
|
-
trigger.textContent = 'Display Form'
|
61
|
-
}
|
62
|
-
})
|
63
|
-
}
|
64
|
-
window.EasyLogin.display_forms();
|
65
|
-
</script>
|
data/lib/easy_login.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require "easy_login/version"
|
2
|
-
require "easy_login/engine"
|
3
|
-
|
4
|
-
module EasyLogin
|
5
|
-
extend ActiveSupport::Autoload
|
6
|
-
autoload :Helpers
|
7
|
-
|
8
|
-
mattr_accessor :klass_names
|
9
|
-
@@klass_names = ['User']
|
10
|
-
|
11
|
-
def self.klasses
|
12
|
-
@@klasses = EasyLogin.klass_names.map(&:constantize)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
require 'easy_login/routes'
|
data/lib/easy_login/engine.rb
DELETED
data/lib/easy_login/helpers.rb
DELETED
data/lib/easy_login/routes.rb
DELETED
data/lib/easy_login/version.rb
DELETED