decidim-idcat_mobil 0.0.9 → 0.2.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 +1 -1
- data/app/events/decidim/idcat_mobil/verification_invalid_notification.rb +3 -2
- data/app/events/decidim/idcat_mobil/verification_success_notification.rb +3 -2
- data/app/forms/decidim/verifications/id_cat_mobil_handler.rb +11 -7
- data/app/jobs/decidim/idcat_mobil/verification_job.rb +4 -3
- data/app/packs/entrypoints/decidim-idcat_mobil.js +2 -0
- data/app/{assets/images/decidim/idcat_mobil/icon.svg → packs/images/idcat_mobil-icon.svg} +0 -0
- data/config/assets.rb +16 -0
- data/config/initializers/omniauth_idcat_mobil.rb +12 -10
- data/lib/decidim/idcat_mobil/admin.rb +2 -0
- data/lib/decidim/idcat_mobil/admin_engine.rb +2 -0
- data/lib/decidim/idcat_mobil/component.rb +2 -0
- data/lib/decidim/idcat_mobil/engine.rb +3 -15
- data/lib/decidim/idcat_mobil/version.rb +5 -1
- metadata +20 -19
- data/app/assets/config/decidim_idcat_mobil_manifest.js +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62fd4e5c790bf8b6ca4cd394116ba472ffca3423f5bd11b7835dcd57387fd634
|
4
|
+
data.tar.gz: 6fcc2cdd7f9b72a646656e084b7e7fc5f09b6cef85b93a6672580e86325e181b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0aa67ef9ff8b221c76bc4123bde06a5a7d5571a3cfcd4bc1bad7565520801a7b5f3e032e0aee68faa6dbac5ab68011567c6d1b0ac3029e1a61e1c43575734954
|
7
|
+
data.tar.gz: 1a9e06f2c05666bf56c97771a8d7d989e75428965153adeb31771d9d9ee54418754b687f46fd08920e10aed5a9d18fb385d755052749278514015c6f7cba37dc
|
data/README.md
CHANGED
@@ -31,7 +31,7 @@ Check how to configure the strategy in [Decidim's related documentation](https:/
|
|
31
31
|
omniauth:
|
32
32
|
idcat_mobil:
|
33
33
|
enabled: true
|
34
|
-
icon_path: decidim/idcat_mobil/icon.svg
|
34
|
+
icon_path: decidim/idcat_mobil/idcat_mobil-icon.svg
|
35
35
|
```
|
36
36
|
|
37
37
|
Remember to set `IDCAT_MOBIL_CLIENT_ID`, `IDCAT_MOBIL_CLIENT_SECRET` and `IDCAT_MOBIL_SITE_URL` environment variables.
|
@@ -7,14 +7,14 @@ module Decidim
|
|
7
7
|
attribute :oauth_data, Hash
|
8
8
|
|
9
9
|
validates :unique_id, presence: true
|
10
|
-
validate :
|
10
|
+
validate :idcatmobil_method?, :has_ok_status?
|
11
11
|
|
12
12
|
def unique_id
|
13
|
-
oauth_data[
|
13
|
+
oauth_data["identifier"]
|
14
14
|
end
|
15
15
|
|
16
16
|
def metadata
|
17
|
-
|
17
|
+
oauth_data
|
18
18
|
end
|
19
19
|
|
20
20
|
def user
|
@@ -23,15 +23,19 @@ module Decidim
|
|
23
23
|
|
24
24
|
#-----------------------------------------------------------
|
25
25
|
private
|
26
|
+
|
26
27
|
#-----------------------------------------------------------
|
27
28
|
|
28
|
-
def
|
29
|
-
return true if oauth_data[
|
29
|
+
def idcatmobil_method?
|
30
|
+
return true if oauth_data["method"] == "idcatmobil"
|
31
|
+
|
30
32
|
errors.add(:base, I18n.t("decidim.verifications.idcat_mobil.errors.invalid_method"))
|
31
33
|
false
|
32
34
|
end
|
33
|
-
|
34
|
-
|
35
|
+
|
36
|
+
def has_ok_status?
|
37
|
+
return true if oauth_data["status"] == "ok"
|
38
|
+
|
35
39
|
errors.add(:base, I18n.t("decidim.verifications.idcat_mobil.errors.invalid_status"))
|
36
40
|
false
|
37
41
|
end
|
@@ -6,7 +6,7 @@ module Decidim
|
|
6
6
|
queue_as :default
|
7
7
|
|
8
8
|
def perform(oauth_data)
|
9
|
-
handler= retrieve_handler(oauth_data)
|
9
|
+
handler = retrieve_handler(oauth_data)
|
10
10
|
Decidim::Verifications::AuthorizeUser.call(handler) do
|
11
11
|
on(:ok) do
|
12
12
|
notify_user(handler.user, :ok, handler)
|
@@ -20,15 +20,16 @@ module Decidim
|
|
20
20
|
|
21
21
|
#-----------------------------------------------------------
|
22
22
|
private
|
23
|
+
|
23
24
|
#-----------------------------------------------------------
|
24
25
|
|
25
26
|
# Retrieves handler from Verification workflows registry.
|
26
27
|
def retrieve_handler(oauth_data)
|
27
|
-
Decidim::AuthorizationHandler.handler_for(
|
28
|
+
Decidim::AuthorizationHandler.handler_for("idcat_mobil", oauth_data: oauth_data)
|
28
29
|
end
|
29
30
|
|
30
31
|
def notify_user(user, status, handler)
|
31
|
-
notification_class= status == :ok ? Decidim::IdcatMobil::VerificationSuccessNotification : Decidim::IdcatMobil::VerificationInvalidNotification
|
32
|
+
notification_class = status == :ok ? Decidim::IdcatMobil::VerificationSuccessNotification : Decidim::IdcatMobil::VerificationInvalidNotification
|
32
33
|
Decidim::EventsManager.publish(
|
33
34
|
event: "decidim.verifications.idcat_mobil.#{status}",
|
34
35
|
event_class: notification_class,
|
File without changes
|
data/config/assets.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This file is located at `config/assets.rb` of your module.
|
4
|
+
|
5
|
+
base_path = File.expand_path("..", __dir__)
|
6
|
+
|
7
|
+
# Register the additonal path for Webpacker in order to make the module's
|
8
|
+
# stylesheets available for inclusion.
|
9
|
+
Decidim::Webpacker.register_path("#{base_path}/app/packs")
|
10
|
+
|
11
|
+
# Register the main application's stylesheet include statement:
|
12
|
+
# Decidim::Webpacker.register_stylesheet_import("stylesheets/decidim/your_component/your_component")
|
13
|
+
# Register the admin panel's stylesheet include statement:
|
14
|
+
|
15
|
+
# Register JS entrypoints
|
16
|
+
Decidim::Webpacker.register_entrypoints(decidim_idcat_mobil: "#{base_path}/app/packs/entrypoints/decidim-idcat_mobil.js")
|
@@ -1,18 +1,20 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
OmniAuth.config.logger = Rails.logger
|
2
4
|
|
3
5
|
if Rails.application.secrets.dig(:omniauth, :idcat_mobil).present?
|
4
6
|
Rails.application.config.middleware.use OmniAuth::Builder do
|
5
7
|
provider(
|
6
8
|
:idcat_mobil,
|
7
|
-
setup:
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
setup: lambda { |env|
|
10
|
+
request = Rack::Request.new(env)
|
11
|
+
organization = Decidim::Organization.find_by(host: request.host)
|
12
|
+
provider_config = organization.enabled_omniauth_providers[:idcat_mobil]
|
13
|
+
env["omniauth.strategy"].options[:client_id] = provider_config[:client_id] || ENV["IDCAT_MOBIL_CLIENT_ID"]
|
14
|
+
env["omniauth.strategy"].options[:client_secret] = provider_config[:client_secret] || ENV["IDCAT_MOBIL_CLIENT_SECRET"]
|
15
|
+
env["omniauth.strategy"].options[:site] = provider_config[:site_url] || ENV["IDCAT_MOBIL_SITE_URL"]
|
16
|
+
},
|
15
17
|
scope: :autenticacio_usuari
|
16
18
|
)
|
17
19
|
end
|
18
|
-
end
|
20
|
+
end
|
@@ -16,21 +16,9 @@ module Decidim
|
|
16
16
|
# root to: "idcat_mobil#index"
|
17
17
|
end
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
# #
|
23
|
-
# initializer "decidim.middleware" do |app|
|
24
|
-
# # as `app.config.middleware` is just a proxy made available for configuration purposes
|
25
|
-
# # and acts as a command recorder that executes deletes always at the end
|
26
|
-
# # we can not remove and re-insert, but only duplicate `Decidim::CurrentOrganization`.
|
27
|
-
# # app.config.middleware.delete Decidim::CurrentOrganization
|
28
|
-
# app.config.middleware.insert_before Warden::Manager, Decidim::CurrentOrganization
|
29
|
-
# end
|
30
|
-
|
31
|
-
# initializer "decidim_idcat_mobil.assets" do |app|
|
32
|
-
# app.config.assets.precompile += %w[decidim_idcat_mobil_manifest.js decidim_idcat_mobil_manifest.css]
|
33
|
-
# end
|
19
|
+
initializer "decidim_idcat_mobil.webpacker.assets_path" do
|
20
|
+
Decidim.register_assets_path File.expand_path("app/packs", root)
|
21
|
+
end
|
34
22
|
end
|
35
23
|
end
|
36
24
|
end
|
metadata
CHANGED
@@ -1,71 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: decidim-idcat_mobil
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oliver Valls
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: decidim
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.2
|
19
|
+
version: 0.25.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.2
|
26
|
+
version: 0.25.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name: decidim
|
28
|
+
name: decidim-core
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.25.2
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: 0.25.2
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: omniauth-idcat_mobil
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
47
|
+
version: 0.4.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
54
|
+
version: 0.4.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: decidim-dev
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
61
|
+
version: 0.25.2
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.
|
68
|
+
version: 0.25.2
|
69
69
|
description: User registration, login and verification though VÀLid's IdCat mòbil..
|
70
70
|
email:
|
71
71
|
- oliver.vh@coditramuntana.com
|
@@ -76,8 +76,6 @@ files:
|
|
76
76
|
- LICENSE-AGPLv3.txt
|
77
77
|
- README.md
|
78
78
|
- Rakefile
|
79
|
-
- app/assets/config/decidim_idcat_mobil_manifest.js
|
80
|
-
- app/assets/images/decidim/idcat_mobil/icon.svg
|
81
79
|
- app/controllers/decidim/idcat_mobil/admin/application_controller.rb
|
82
80
|
- app/controllers/decidim/idcat_mobil/application_controller.rb
|
83
81
|
- app/events/decidim/idcat_mobil/verification_invalid_notification.rb
|
@@ -87,6 +85,9 @@ files:
|
|
87
85
|
- app/jobs/decidim/idcat_mobil/application_job.rb
|
88
86
|
- app/jobs/decidim/idcat_mobil/verification_job.rb
|
89
87
|
- app/models/decidim/idcat_mobil/application_record.rb
|
88
|
+
- app/packs/entrypoints/decidim-idcat_mobil.js
|
89
|
+
- app/packs/images/idcat_mobil-icon.svg
|
90
|
+
- config/assets.rb
|
90
91
|
- config/i18n-tasks.yml
|
91
92
|
- config/initializers/omniauth_idcat_mobil.rb
|
92
93
|
- config/locales/ca.yml
|
File without changes
|