any_login_multiple 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +39 -0
- data/Rakefile +18 -0
- data/app/controllers/easy_login/application_controller.rb +15 -0
- data/app/helpers/easy_login/application_helper.rb +7 -0
- data/app/views/easy_login/_easy_login.html.erb +65 -0
- data/config/routes.rb +7 -0
- data/lib/easy_login.rb +16 -0
- data/lib/easy_login/engine.rb +11 -0
- data/lib/easy_login/helpers.rb +9 -0
- data/lib/easy_login/routes.rb +7 -0
- data/lib/easy_login/version.rb +3 -0
- metadata +92 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b0401e670329ebdd24333641ba6cf55aef7e6f1109cae162e68c2d0776fdaad1
|
4
|
+
data.tar.gz: 8637a30170006164e1f410ebb05451210e1cbd010b3f29ef06db1c5639c5a926
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a6f6808f8fe997c82843558fb6428f09a7f51c94bf407b5ab6322d1d0d1da55f1027f29f0b20e44ddff8874749ed9fdbd0a556e9403446d6d6cef8488e98e839
|
7
|
+
data.tar.gz: 7e8193f0dbc3f02fc600f6b303710c984e89673deb6715eac634b8146a5210249f8fbfcb4d19ee279fa33e1b67f79557510fffa502c3f0301845b371008e8b0e
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2021 kenzo-tanaka
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# EasyLogin
|
2
|
+
|
3
|
+
This gem is inspired by [any_login](https://github.com/igorkasyanchuk/any_login).
|
4
|
+
This gem supports multiple model support.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
First of all, this gem only work in an environment
|
9
|
+
where [devise](https://github.com/heartcombo/devise) is installed.
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
group :development do
|
15
|
+
gem 'easy_login'
|
16
|
+
end
|
17
|
+
```
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
```bash
|
21
|
+
$ bundle install
|
22
|
+
```
|
23
|
+
|
24
|
+
Add `config/initializers/easy_login.rb` and set `klass_names`:
|
25
|
+
|
26
|
+
```rb
|
27
|
+
EasyLogin.klass_names = ['User', 'Staff']
|
28
|
+
```
|
29
|
+
|
30
|
+
## Usage
|
31
|
+
|
32
|
+
Add this line to `application.html.erb`:
|
33
|
+
|
34
|
+
```erb
|
35
|
+
<%= easy_login_here if Rails.env.development? %>
|
36
|
+
```
|
37
|
+
|
38
|
+
## License
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require "bundler/setup"
|
2
|
+
|
3
|
+
APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
|
4
|
+
load "rails/tasks/engine.rake"
|
5
|
+
|
6
|
+
load "rails/tasks/statistics.rake"
|
7
|
+
|
8
|
+
require "bundler/gem_tasks"
|
9
|
+
|
10
|
+
require "rake/testtask"
|
11
|
+
|
12
|
+
Rake::TestTask.new(:test) do |t|
|
13
|
+
t.libs << 'test'
|
14
|
+
t.pattern = 'test/**/*_test.rb'
|
15
|
+
t.verbose = false
|
16
|
+
end
|
17
|
+
|
18
|
+
task default: :test
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module EasyLogin
|
2
|
+
class ApplicationController < ActionController::Base
|
3
|
+
def easy_login
|
4
|
+
reset_session
|
5
|
+
|
6
|
+
klass_string = params[:as]
|
7
|
+
@user = klass_string.constantize.find(params[:id])
|
8
|
+
|
9
|
+
# Call devise sign in method
|
10
|
+
sign_in klass_string.parameterize.underscore.to_sym, @user
|
11
|
+
|
12
|
+
redirect_to main_app.root_path
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,65 @@
|
|
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/config/routes.rb
ADDED
data/lib/easy_login.rb
ADDED
@@ -0,0 +1,16 @@
|
|
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'
|
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: any_login_multiple
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- kenzo-tanaka
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-08-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: devise
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rails
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 6.1.4
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 6.1.4.1
|
37
|
+
type: :runtime
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 6.1.4
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 6.1.4.1
|
47
|
+
description: Easy login with devise, multiple model
|
48
|
+
email:
|
49
|
+
- kenzou.kenzou104809@gmail.com
|
50
|
+
executables: []
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- MIT-LICENSE
|
55
|
+
- README.md
|
56
|
+
- Rakefile
|
57
|
+
- app/controllers/easy_login/application_controller.rb
|
58
|
+
- app/helpers/easy_login/application_helper.rb
|
59
|
+
- app/views/easy_login/_easy_login.html.erb
|
60
|
+
- config/routes.rb
|
61
|
+
- lib/easy_login.rb
|
62
|
+
- lib/easy_login/engine.rb
|
63
|
+
- lib/easy_login/helpers.rb
|
64
|
+
- lib/easy_login/routes.rb
|
65
|
+
- lib/easy_login/version.rb
|
66
|
+
homepage: https://github.com/kenzo-tanaka/easy_login
|
67
|
+
licenses:
|
68
|
+
- MIT
|
69
|
+
metadata:
|
70
|
+
homepage_uri: https://github.com/kenzo-tanaka/easy_login
|
71
|
+
source_code_uri: https://github.com/kenzo-tanaka/easy_login
|
72
|
+
changelog_uri: https://github.com/kenzo-tanaka/easy_login/blob/main/CHANGELOG.md
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options: []
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
requirements: []
|
88
|
+
rubygems_version: 3.1.6
|
89
|
+
signing_key:
|
90
|
+
specification_version: 4
|
91
|
+
summary: Easy login with devise, multiple model
|
92
|
+
test_files: []
|