dscf-core 0.3.14 → 0.3.15
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 +4 -4
- data/app/controllers/dscf/core/auth_controller.rb +55 -48
- data/lib/dscf/core/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8d0212cd56d88328433f2976b536c39cdbbe16a240b2ab3ede3a9ed25e07818b
|
|
4
|
+
data.tar.gz: 16d3d5cfb125698800e11250de6c53d03747962acaa4a63899fb326ae482be62
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 95fc979d818ab2875ab6426f224eb06bcd39e4faea8fbf94896ba5236ae82d9d584ee1fb71955c25c9231b02b6f7c31b61f3cf82eacbb78aaa325a1a68efa114
|
|
7
|
+
data.tar.gz: 824300b9d0ed578d6b600bf150c0bf10992c227c5a20071e4162230f50e263998555d86f9156598ce5402484421712bce41baef28baf510e08c57089b0cfa833
|
|
@@ -41,6 +41,8 @@ module Dscf
|
|
|
41
41
|
|
|
42
42
|
def signup
|
|
43
43
|
skip_authorization
|
|
44
|
+
return signup_retailer if params[:retailer].present?
|
|
45
|
+
|
|
44
46
|
user = User.new(user_params)
|
|
45
47
|
|
|
46
48
|
return render_error("auth.errors.missing_email_or_phone") unless user.email.present? || user.phone.present?
|
|
@@ -58,8 +60,6 @@ module Dscf
|
|
|
58
60
|
|
|
59
61
|
# Optionally create marketplace records when onboarding via mobile app
|
|
60
62
|
create_agent_from_signup!(user) if params[:agent].present?
|
|
61
|
-
create_retailer_from_signup!(user) if params[:retailer].present?
|
|
62
|
-
|
|
63
63
|
user_with_includes = User.includes(roles: :permissions, user_profile: {}).find(user.id)
|
|
64
64
|
render_success(
|
|
65
65
|
"auth.success.signup",
|
|
@@ -129,7 +129,7 @@ module Dscf
|
|
|
129
129
|
:password,
|
|
130
130
|
:password_confirmation,
|
|
131
131
|
:temp_password,
|
|
132
|
-
user_profile_attributes: %i[first_name last_name date_of_birth
|
|
132
|
+
user_profile_attributes: %i[first_name last_name gender date_of_birth]
|
|
133
133
|
)
|
|
134
134
|
end
|
|
135
135
|
|
|
@@ -150,53 +150,46 @@ module Dscf
|
|
|
150
150
|
)
|
|
151
151
|
end
|
|
152
152
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
# `authenticate_user` is skipped for this action so self-service
|
|
158
|
-
# signup stays public, but `current_user` still resolves whatever
|
|
159
|
-
# Bearer token was sent — an agent onboarding a retailer on their
|
|
160
|
-
# behalf attaches their own token, so we derive the onboarding
|
|
161
|
-
# agent from it rather than trusting a client-supplied agent_id
|
|
162
|
-
# (there is none in this params shape today, but this keeps the
|
|
163
|
-
# same trust model as the rest of the agent-assisted flows).
|
|
164
|
-
# Guard on current_user first: find_by(user_id: nil) matches any
|
|
165
|
-
# Agent row with a null user_id, silently attributing anonymous
|
|
166
|
-
# self-signups to a random agent (confirmed live in dscf_marketplace's
|
|
167
|
-
# equivalent bug — same fix applied here).
|
|
168
|
-
onboarding_agent = if current_user && defined?(Dscf::Marketplace::Agent)
|
|
169
|
-
Dscf::Marketplace::Agent.find_by(user_id: current_user.id)
|
|
153
|
+
def signup_retailer
|
|
154
|
+
unless defined?(Dscf::Marketplace::Retailer::Registration)
|
|
155
|
+
return render_error(errors: ["Retailer registration is unavailable"], status: :unprocessable_entity)
|
|
170
156
|
end
|
|
171
157
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
onboarded_at: (Time.current if onboarding_agent)
|
|
180
|
-
)
|
|
158
|
+
registration = Dscf::Marketplace::Retailer::Registration.new(
|
|
159
|
+
user_attributes: user_params,
|
|
160
|
+
retailer_attributes: retailer_signup_params,
|
|
161
|
+
address_attributes: address_signup_params,
|
|
162
|
+
actor: current_user,
|
|
163
|
+
obsolete_profile_address: obsolete_profile_address?
|
|
164
|
+
).create!
|
|
181
165
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
166
|
+
user_with_includes = User.includes(roles: :permissions, user_profile: {}).find(registration.user.id)
|
|
167
|
+
render_success(
|
|
168
|
+
"auth.success.signup",
|
|
169
|
+
data: {
|
|
170
|
+
user: user_with_includes,
|
|
171
|
+
retailer: registration.retailer,
|
|
172
|
+
address: registration.address
|
|
173
|
+
},
|
|
174
|
+
status: :created,
|
|
175
|
+
serializer_options: {
|
|
176
|
+
user: {
|
|
177
|
+
serializer: Dscf::Core::UserAuthSerializer,
|
|
178
|
+
include: [:user_profile, roles: [:permissions]]
|
|
179
|
+
},
|
|
180
|
+
retailer: {
|
|
181
|
+
serializer: Dscf::Marketplace::RetailerSerializer
|
|
182
|
+
},
|
|
183
|
+
address: {
|
|
184
|
+
serializer: Dscf::Core::AddressSerializer
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
)
|
|
188
|
+
rescue Dscf::Marketplace::Retailer::Registration::InvalidInput => e
|
|
189
|
+
render_error("auth.errors.signup_failed", errors: e.errors, status: :unprocessable_entity)
|
|
190
|
+
rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotSaved => e
|
|
191
|
+
errors = e.respond_to?(:record) && e.record ? e.record.errors.full_messages : [e.message]
|
|
192
|
+
render_error("auth.errors.signup_failed", errors: errors, status: :unprocessable_entity)
|
|
200
193
|
end
|
|
201
194
|
|
|
202
195
|
def agent_signup_params
|
|
@@ -204,7 +197,21 @@ module Dscf
|
|
|
204
197
|
end
|
|
205
198
|
|
|
206
199
|
def retailer_signup_params
|
|
207
|
-
params.fetch(:retailer, {}).permit(
|
|
200
|
+
params.fetch(:retailer, {}).permit(
|
|
201
|
+
:name, :phone, :tin_number, :location, :branch_count,
|
|
202
|
+
preferred_category_ids: []
|
|
203
|
+
)
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
def address_signup_params
|
|
207
|
+
params.fetch(:address, {}).permit(
|
|
208
|
+
:country, :city, :sub_city, :woreda, :kebele,
|
|
209
|
+
:house_numbers, :po_box, :latitude, :longitude
|
|
210
|
+
)
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
def obsolete_profile_address?
|
|
214
|
+
params.dig(:user, :user_profile_attributes)&.key?(:address)
|
|
208
215
|
end
|
|
209
216
|
end
|
|
210
217
|
end
|
data/lib/dscf/core/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dscf-core
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.15
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Asrat
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 2026-07-30 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: rails
|
|
@@ -589,7 +589,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
589
589
|
- !ruby/object:Gem::Version
|
|
590
590
|
version: '0'
|
|
591
591
|
requirements: []
|
|
592
|
-
rubygems_version: 3.6.
|
|
592
|
+
rubygems_version: 3.6.2
|
|
593
593
|
specification_version: 4
|
|
594
594
|
summary: An Engine for Supply Chain Financing
|
|
595
595
|
test_files: []
|