decidim-idcat_mobil 0.0.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ad2dd80b7150ea972b3df81bf681756ad34bc19e77575f2fd9d7ec72e9dc66a8
4
- data.tar.gz: 4591b46f4ee3fa345c05ed9bcc1ce2c0372638e43a1d758f60bfa654cc8860bf
3
+ metadata.gz: 23d738c9fde7cd2069188887f0290aa1605e9993c3aaf77aab18dc4f15d15808
4
+ data.tar.gz: b6f5ccf8a4e8b876d37f1f23f5bb3c2809ef0ae9fd9a56322638003ddaceeff3
5
5
  SHA512:
6
- metadata.gz: 5a0818025584f868ba3b649ed7a3981db7f9f5b7963ef776be22ccadd40be147ad8a08a99be43cac546196273b5a0421f4661cec672339594aa307e878f98045
7
- data.tar.gz: f46714c8a872fd25d2637fe6d7d7b16519af86a155277fdf9fa9b45b4a765c49e194161a85db8cc652a22be839178e309d992c518194b3872eba001492b6a8d0
6
+ metadata.gz: b789de69eaee60be5a5e0dd6543d9e521ee11346e76787f1026305048ea5477c2556b587f39ab4dd7666904cf321fea876eabc88e0ce4b421052927771adcd51
7
+ data.tar.gz: eb16a519d19e55dd74fc74c46b974af258e3aaf456e19caa9cd9947f0f76e9493495e940e707fd4a6ba338694e10a60b82d7e23e1790615393c4722f84c7590a
@@ -4,10 +4,11 @@ module Decidim
4
4
  module IdcatMobil
5
5
  class VerificationInvalidNotification < Decidim::Events::SimpleEvent
6
6
  def resource_path
7
- 'http'
7
+ "http"
8
8
  end
9
+
9
10
  def resource_url
10
- 'http'
11
+ "http"
11
12
  end
12
13
  end
13
14
  end
@@ -4,10 +4,11 @@ module Decidim
4
4
  module IdcatMobil
5
5
  class VerificationSuccessNotification < Decidim::Events::SimpleEvent
6
6
  def resource_path
7
- 'http'
7
+ "http"
8
8
  end
9
+
9
10
  def resource_url
10
- 'http'
11
+ "http"
11
12
  end
12
13
  end
13
14
  end
@@ -7,14 +7,14 @@ module Decidim
7
7
  attribute :oauth_data, Hash
8
8
 
9
9
  validates :unique_id, presence: true
10
- validate :is_idcatmobil_method, :has_ok_status
10
+ validate :idcatmobil_method?, :has_ok_status?
11
11
 
12
12
  def unique_id
13
- oauth_data['identifier']
13
+ oauth_data["identifier"]
14
14
  end
15
15
 
16
16
  def metadata
17
- oauth_data
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 is_idcatmobil_method
29
- return true if oauth_data['method'] == 'idcatmobil'
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
- def has_ok_status
34
- return true if oauth_data['status'] == 'ok'
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('idcat_mobil', oauth_data: oauth_data)
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,
@@ -1,18 +1,20 @@
1
- OmniAuth.config.logger= Rails.logger
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: ->(env) {
8
- request = Rack::Request.new(env)
9
- organization = Decidim::Organization.find_by(host: request.host)
10
- provider_config = organization.enabled_omniauth_providers[:idcat_mobil]
11
- env["omniauth.strategy"].options[:client_id] = provider_config[:client_id] || ENV["IDCAT_MOBIL_CLIENT_ID"]
12
- env["omniauth.strategy"].options[:client_secret] = provider_config[:client_secret] || ENV["IDCAT_MOBIL_CLIENT_SECRET"]
13
- env["omniauth.strategy"].options[:site] = provider_config[:site_url] || ENV["IDCAT_MOBIL_SITE_URL"]
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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # # frozen_string_literal: true
2
4
 
3
5
  # module Decidim
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # # frozen_string_literal: true
2
4
 
3
5
  # module Decidim
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # # frozen_string_literal: true
2
4
 
3
5
  # require_dependency "decidim/components/namer"
@@ -4,7 +4,11 @@ module Decidim
4
4
  module IdcatMobil
5
5
  def self.version
6
6
  # See CHANGELOG.md to see what changed
7
- "0.0.9"
7
+ "0.1.0"
8
+ end
9
+
10
+ def self.decidim_version
11
+ "0.24.0"
8
12
  end
9
13
  end
10
14
  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.0.9
4
+ version: 0.1.0
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-01-31 00:00:00.000000000 Z
11
+ date: 2022-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: omniauth-idcat_mobil
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.4
19
+ version: 0.24.0
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.4
26
+ version: 0.24.0
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.20.0
33
+ version: 0.24.0
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.20.0
40
+ version: 0.24.0
41
41
  - !ruby/object:Gem::Dependency
42
- name: decidim-core
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.20.0
47
+ version: 0.3.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.20.0
54
+ version: 0.3.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.20.0
61
+ version: 0.24.0
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.20.0
68
+ version: 0.24.0
69
69
  description: User registration, login and verification though VÀLid's IdCat mòbil..
70
70
  email:
71
71
  - oliver.vh@coditramuntana.com