contrib-auth 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ef320c78fd097c24090a4635394bad139b57dbed7ef3e78998238afc9243dc10
4
- data.tar.gz: f0482456dd9e97403bcaf3c2015d44c28154d61c86aa93721945aa3645ba855d
3
+ metadata.gz: 0c1695b4715a11c8631ac8a52cf6839a1497ecc621e87d4404bc2c7a6c14fe6a
4
+ data.tar.gz: 7c3702e193cae4e60772a35b3940691a90a34c56b8cd18cc8f1bbf508db876cb
5
5
  SHA512:
6
- metadata.gz: 3ad3e8db46f1e149228455398dce3842ac964403e02f6e4c2dd4e90b38489954f8e5045cd13acf229e772d5900c3d8c674e206ea44ea9bdf67f239cbf699a495
7
- data.tar.gz: 155144638f18b43ab8e18cb065c26a4be7cc46c4ab1455f333127cfe1ee2d6546e928c211b54440435b895dee92f8494ae5fec237e2ff23f2b5e2ec8ce701bbb
6
+ metadata.gz: ac13c1ae9640fb29c2efde87293465e8a56b11d9a0103be1a838300b8ee57a77956a830aa538d527c8b75eef6ec66b009195bcc4c3700cb8d10221d0dbabe322
7
+ data.tar.gz: fb3750efea0e27c842ae6ab691639e66d0490af6fb29cefda8e56de850fe458ad5e41c1472813f543abd445045894b3d5cb5529c5897dc24f431a14ac0285d23
@@ -23,6 +23,14 @@ module Contrib
23
23
  )
24
24
  end
25
25
 
26
+ def change_password
27
+ @response = Contrib::Auth.api.change_password(
28
+ params[:id_token],
29
+ params[:password],
30
+ params[:password_confirmation],
31
+ )
32
+ end
33
+
26
34
  def certificates
27
35
  render json: Contrib::Auth.api.certificates, status: :ok
28
36
  end
@@ -0,0 +1 @@
1
+ json.extract!(@response, :id_token, :refresh_token, :expires_in, :email)
data/config/routes.rb CHANGED
@@ -2,7 +2,8 @@ Contrib::Auth::Engine.routes.draw do
2
2
  defaults format: :json do
3
3
  post '/sign_in_with_password' => 'authentication#sign_in_with_password'
4
4
  post '/reset_password' => 'authentication#reset_password'
5
- post '/sign_up_with_email_or_username_and_password' => 'authentication#sign_up_with_email_or_username_and_password'
5
+ post '/change_password' => 'authentication#change_password'
6
6
  get '/certificates' => 'authentication#certificates'
7
+ post '/sign_up_with_email_or_username_and_password' => 'authentication#sign_up_with_email_or_username_and_password'
7
8
  end
8
9
  end
@@ -25,6 +25,12 @@ module Contrib
25
25
  @provider.sign_up_with_email_and_password(email_or_username, password)
26
26
  end
27
27
 
28
+ def change_password(id_token, password, password_confirmation)
29
+ raise ArgumentError unless password == password_confirmation
30
+
31
+ @provider.change_password(id_token, password)
32
+ end
33
+
28
34
  def certificates
29
35
  @provider.certificates
30
36
  end
@@ -77,6 +77,28 @@ module Contrib
77
77
  response = @http_client.get(PUBLIC_KEYS_URI)
78
78
  JSON.parse(response.body)
79
79
  end
80
+
81
+ def change_password(id_token, password)
82
+ response = @http_client.post('/v1/accounts:update') do |req|
83
+ req.params[:key] = @api_key
84
+ req.headers['Content-Type'] = 'application/json'
85
+
86
+ req.body = JSON.generate(
87
+ idToken: id_token,
88
+ password: password,
89
+ returnSecureToken: true,
90
+ )
91
+ end
92
+
93
+ parsed_response = JSON.parse(response.body)
94
+
95
+ Contrib::Auth::Provider::Responses::ChangePassword.new(
96
+ id_token: parsed_response['idToken'],
97
+ refresh_token: parsed_response['refreshToken'],
98
+ expires_in: parsed_response['expiresIn'],
99
+ email: parsed_response['email'],
100
+ )
101
+ end
80
102
  end
81
103
  end
82
104
  end
@@ -0,0 +1,20 @@
1
+ module Contrib
2
+ module Auth
3
+ module Provider
4
+ module Responses
5
+ class ChangePassword
6
+ attr_accessor :id_token
7
+ attr_accessor :refresh_token
8
+ attr_accessor :expires_in
9
+ attr_accessor :email
10
+
11
+ def initialize(params = {})
12
+ params.each do |param, key|
13
+ public_send("#{param}=", key)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,2 +1,3 @@
1
1
  require 'contrib/auth/provider/responses/sign_in_with_password'
2
2
  require 'contrib/auth/provider/responses/sign_up_with_email_and_password'
3
+ require 'contrib/auth/provider/responses/change_password'
@@ -1,5 +1,5 @@
1
1
  module Contrib
2
2
  module Auth
3
- VERSION = '0.4.1'
3
+ VERSION = '0.4.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,22 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contrib-auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Contribyard Developers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-29 00:00:00.000000000 Z
11
+ date: 2023-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: 6.1.4
20
17
  - - ">="
21
18
  - !ruby/object:Gem::Version
22
19
  version: 6.1.4.1
@@ -24,9 +21,6 @@ dependencies:
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - "~>"
28
- - !ruby/object:Gem::Version
29
- version: 6.1.4
30
24
  - - ">="
31
25
  - !ruby/object:Gem::Version
32
26
  version: 6.1.4.1
@@ -76,6 +70,7 @@ files:
76
70
  - app/jobs/contrib/auth/application_job.rb
77
71
  - app/mailers/contrib/auth/application_mailer.rb
78
72
  - app/models/contrib/auth/application_record.rb
73
+ - app/views/contrib/auth/authentication/change_password.json.jbuilder
79
74
  - app/views/contrib/auth/authentication/sign_in_with_password.json.jbuilder
80
75
  - app/views/contrib/auth/authentication/sign_up_with_email_or_username_and_password.json.jbuilder
81
76
  - config/routes.rb
@@ -85,6 +80,7 @@ files:
85
80
  - lib/contrib/auth/engine.rb
86
81
  - lib/contrib/auth/provider/google_auth.rb
87
82
  - lib/contrib/auth/provider/responses.rb
83
+ - lib/contrib/auth/provider/responses/change_password.rb
88
84
  - lib/contrib/auth/provider/responses/sign_in_with_password.rb
89
85
  - lib/contrib/auth/provider/responses/sign_up_with_email_and_password.rb
90
86
  - lib/contrib/auth/version.rb
@@ -109,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
105
  - !ruby/object:Gem::Version
110
106
  version: '0'
111
107
  requirements: []
112
- rubygems_version: 3.2.22
108
+ rubygems_version: 3.4.10
113
109
  signing_key:
114
110
  specification_version: 4
115
111
  summary: Vendor-agnostic authentication component for Rails APIs