Skip to content

Commit 91fca6d

Browse files
update phone auth, idv, api dropdown
2 parents 6b7b033 + 05e0338 commit 91fca6d

19 files changed

+265
-184
lines changed

Gemfile.lock

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ GEM
9797
json (~> 2.1, >= 2.1.0)
9898
jwt (~> 2.2, >= 2.2.1)
9999
typhoeus (~> 1.0, >= 1.0.1)
100-
docusign_esign (3.13.0.rc1)
100+
docusign_esign (3.13.0)
101101
addressable (~> 2.7, >= 2.7.0)
102102
json (~> 2.1, >= 2.1.0)
103103
jwt (~> 2.2, >= 2.2.1)
@@ -113,10 +113,10 @@ GEM
113113
jwt (~> 2.2, >= 2.2.1)
114114
typhoeus (~> 1.0, >= 1.0.1)
115115
erubi (1.10.0)
116-
ethon (0.14.0)
116+
ethon (0.15.0)
117117
ffi (>= 1.15.0)
118118
execjs (2.8.1)
119-
faraday (1.7.0)
119+
faraday (1.8.0)
120120
faraday-em_http (~> 1.0)
121121
faraday-em_synchrony (~> 1.0)
122122
faraday-excon (~> 1.1)
@@ -135,17 +135,17 @@ GEM
135135
faraday-net_http_persistent (1.2.0)
136136
faraday-patron (1.0.0)
137137
faraday-rack (1.0.0)
138-
ffi (1.15.3)
138+
ffi (1.15.4)
139139
globalid (0.5.2)
140140
activesupport (>= 5.0)
141141
hashie (4.1.0)
142-
i18n (1.8.10)
142+
i18n (1.8.11)
143143
concurrent-ruby (~> 1.0)
144144
io-like (0.3.1)
145145
jbuilder (2.10.2)
146146
activesupport (>= 5.0.0)
147-
json (2.5.1)
148-
jwt (2.2.3)
147+
json (2.6.1)
148+
jwt (2.3.0)
149149
listen (3.2.1)
150150
rb-fsevent (~> 0.10, >= 0.10.3)
151151
rb-inotify (~> 0.9, >= 0.9.10)
@@ -154,9 +154,9 @@ GEM
154154
nokogiri (>= 1.5.9)
155155
mail (2.7.1)
156156
mini_mime (>= 0.1.1)
157-
marcel (1.0.1)
157+
marcel (1.0.2)
158158
method_source (0.9.2)
159-
mini_mime (1.1.1)
159+
mini_mime (1.1.2)
160160
minitest (5.14.4)
161161
msgpack (1.4.2)
162162
multi_json (1.15.0)
@@ -177,7 +177,7 @@ GEM
177177
hashie (>= 3.4.6)
178178
rack (>= 1.6.2, < 3)
179179
rack-protection
180-
omniauth-oauth2 (1.7.1)
180+
omniauth-oauth2 (1.7.2)
181181
oauth2 (~> 1.4)
182182
omniauth (>= 1.9, < 3)
183183
omniauth-rails_csrf_protection (1.0.0)
@@ -191,9 +191,9 @@ GEM
191191
pry-rails (0.3.9)
192192
pry (>= 0.10.4)
193193
public_suffix (4.0.6)
194-
puma (4.3.9)
194+
puma (4.3.10)
195195
nio4r (~> 2.0)
196-
racc (1.5.2)
196+
racc (1.6.0)
197197
rack (2.2.3)
198198
rack-protection (2.1.0)
199199
rack
@@ -279,7 +279,7 @@ GEM
279279
websocket-extensions (0.1.5)
280280
xpath (3.2.0)
281281
nokogiri (~> 1.8)
282-
zeitwerk (2.4.2)
282+
zeitwerk (2.5.1)
283283

284284
PLATFORMS
285285
x86_64-darwin-20

app/controllers/ds_common_controller.rb

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,33 @@ class DsCommonController < ApplicationController
66

77
def index
88
@show_doc = Rails.application.config.documentation
9-
if Rails.configuration.examples_API['Rooms']
9+
if session[:examples_API] == 'Rooms'
1010
render 'room_api/index'
11-
elsif Rails.configuration.examples_API['Click']
11+
elsif session[:examples_API] == 'Click'
1212
render 'clickwrap/index'
13-
elsif Rails.configuration.examples_API['Monitor']
13+
elsif session[:examples_API] == 'Monitor'
1414
render 'monitor_api/index'
15-
elsif Rails.configuration.examples_API['Admin']
15+
elsif session[:examples_API] == 'Admin'
1616
render 'admin_api/index'
1717
else
18+
session[:examples_API] = 'eSignature'
1819
@show_doc = Rails.application.config.documentation
1920
if Rails.configuration.quickstart && session[:been_here].nil?
2021
redirect_to '/eg001'
2122
end
2223
end
2324
end
2425

26+
def choose_api
27+
render 'ds_common/choose_api'
28+
end
29+
30+
def api_selected
31+
session.delete :eg
32+
session[:examples_API] = params[:chosen_api]
33+
redirect_to '/ds/mustAuthenticate'
34+
end
35+
2536
def ds_return
2637
# To break out of the Quickstart loop an example has been completed
2738
session[:been_here] = true
@@ -32,17 +43,17 @@ def ds_return
3243
end
3344

3445
def ds_must_authenticate
35-
if Rails.configuration.examples_API['Monitor']
46+
if session[:examples_API] == 'Monitor'
3647
jwt_auth
3748
end
38-
if Rails.configuration.quickstart
39-
redirect_to('/auth/docusign')
49+
if Rails.configuration.quickstart and session[:been_here].nil? and session[:examples_API] == 'eSignature'
50+
redirect_to "/auth/docusign"
4051
end
4152
@title = 'Authenticate with DocuSign'
4253
@show_doc = Rails.application.config.documentation
4354

4455
if params[:auth] == 'grand-auth'
45-
redirect_to('/auth/docusign')
56+
redirect_to "/auth/docusign"
4657
elsif params[:auth] == 'jwt-auth'
4758
jwt_auth
4859
end
@@ -57,16 +68,16 @@ def jwt_auth
5768
end
5869
else
5970
session['omniauth.state'] = SecureRandom.hex
60-
url = JwtAuth::JwtCreator.consent_url(session['omniauth.state'])
71+
url = JwtAuth::JwtCreator.consent_url(session['omniauth.state'], session['examples_API'])
6172
redirect_to root_path if session[:token].present?
6273
end
63-
if Rails.configuration.examples_API['Rooms']
74+
if session[:examples_API] == 'Rooms'
6475
configuration = DocuSign_Rooms::Configuration.new
6576
api_client = DocuSign_Rooms::ApiClient.new(configuration)
66-
elsif Rails.configuration.examples_API['Click']
77+
elsif session[:examples_API] == 'Click'
6778
configuration = DocuSign_Click::Configuration.new
6879
api_client = DocuSign_Click::ApiClient.new configuration
69-
elsif Rails.configuration.examples_API['Admin']
80+
elsif session[:examples_API] == 'Admin'
7081
configuration = DocuSign_Admin::Configuration.new
7182
api_client = DocuSign_Admin::ApiClient.new configuration
7283
end

app/controllers/e_sign/eg020_phone_authentication_controller.rb

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,18 @@ def create
66
if check_token(minimum_buffer_min)
77
begin
88
results = ESign::Eg020PhoneAuthenticationService.new(request, session).call
9-
session[:envelope_id] = results.envelope_id
10-
@title = 'Require Phone Authentication for a Recipient'
11-
@h1 = 'Require Phone Authentication for a Recipient'
12-
@message = "The envelope has been created and sent!<br/>Envelope ID #{results.envelope_id}."
13-
render 'ds_common/example_done'
9+
if results.to_s == "phone_auth_not_enabled"
10+
@error_code = "IDENTITY_WORKFLOW_INVALID_ID"
11+
@error_message = "The identity workflow ID specified is not valid."
12+
@error_information = "Please contact <a target='_blank' rel='noopener noreferrer' href='https://support.docusign.com/'>Support</a> to enable ID verification in your account."
13+
render 'ds_common/error'
14+
else
15+
session[:envelope_id] = results.envelope_id
16+
@title = 'Require Phone Authentication for a Recipient'
17+
@h1 = 'Require Phone Authentication for a Recipient'
18+
@message = "The envelope has been created and sent!<br/>Envelope ID #{results.envelope_id}."
19+
render 'ds_common/example_done'
20+
end
1421
rescue DocuSign_eSign::ApiError => e
1522
error = JSON.parse e.response_body
1623
@error_code = error['errorCode']

app/controllers/e_sign/eg023_idv_authentication_controller.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ def create
66
if check_token(minimum_buffer_min)
77
begin
88
results = ESign::Eg023IdvAuthenticationService.new(request, session).call
9-
if results.to_s == 'needs_idv_activated'
10-
@title = 'Error'
11-
@h1 = 'Error'
12-
@message = 'Please activate IDV on your account to use this example.'
13-
render 'ds_common/example_done'
14-
9+
if results.to_s == "idv_not_enabled"
10+
@error_code = "IDENTITY_WORKFLOW_INVALID_ID"
11+
@error_message = "The identity workflow ID specified is not valid."
12+
@error_information = "Please contact <a target='_blank' rel='noopener noreferrer' href='https://support.docusign.com/'>Support</a> to enable ID verification in your account."
13+
render 'ds_common/error'
14+
1515
else
1616
@title = 'Envelope sent'
1717
@h1 = 'Envelope sent'

app/controllers/session_controller.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ def destroy
2424
redirect_to root_path
2525
end
2626

27+
# def switch_api
28+
# internal_destroy
29+
# end
30+
2731
# GET /auth/failure
2832
def omniauth_failure
2933
error_msg = "OmniAuth authentication failure message: #{params[:message]} for strategy: #{params[:strategy]} and HTTP_REFERER: #{params[:origin]}"

app/services/admin_api/get_data_service.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ def get_ds_groups
3232

3333
def get_organization_id
3434
worker
35-
puts "\n\n getting org_id \n\n"
3635
accounts_api = DocuSign_Admin::AccountsApi.new(@api_client)
3736
accounts_api.get_organizations().organizations[0].as_json['id']
3837
end

app/services/e_sign/eg020_phone_authentication_service.rb

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ def initialize(request, session)
2424
end
2525

2626
def call
27-
envelope_api = create_envelope_api(args)
27+
if session[:workflow_id].blank?
28+
return "phone_auth_not_enabled"
29+
end
2830

2931
# Construct your envelope JSON body
30-
# Step 3 start
32+
# Step 4 start
3133
envelope_definition = DocuSign_eSign::EnvelopeDefinition.new
3234
envelope_definition.email_subject = 'Please sign this document set'
3335

@@ -64,8 +66,8 @@ def call
6466
input_option.phone_number_list = [phone_number]
6567

6668
identity_verification = DocuSign_eSign::RecipientIdentityVerification.new
67-
6869
identity_verification.workflow_id = session[:workflow_id]
70+
6971
identity_verification.input_options = [input_option]
7072

7173
signer1.identity_verification = identity_verification
@@ -92,30 +94,47 @@ def call
9294
# To request that the envelope be created as a draft, set to "created"
9395
envelope_definition.recipients = recipients
9496
envelope_definition.status = envelope_args[:status]
97+
<<<<<<< HEAD
9598
# Step 3 end
96-
99+
97100
# Call the eSignature REST API
98101
# Step 4 start
99102
results = envelope_api.create_envelope args[:account_id], envelope_definition
100103
# Step 4 end
104+
=======
105+
# Step 4 end
106+
107+
# Call the eSignature REST API
108+
# Step 5 start
109+
envelope_api = create_envelope_api(args)
110+
results = envelope_api.create_envelope args[:account_id], envelope_definition
111+
# Step 5 end
112+
>>>>>>> 05e033800b84776cb28f1e661209b778096626a5
101113
end
102114

103115
def get_workflow(args)
104116
#Retrieve the workflow id
117+
105118
begin
119+
# Step 3 start
106120
workflow_details = create_account_api(args)
107121
workflow_response = workflow_details.get_account_identity_verification(args[:account_id])
108122

109123
# Check that idv authentication is enabled
110-
# The workflow ID is a hard-coded value which is unique to this phone authentication workflow
111124
if workflow_response.identity_verification
112-
session[:workflow_id] = "c368e411-1592-4001-a3df-dca94ac539ae"
125+
phone_auth_workflow = workflow_response.identity_verification.find{ |item| item.default_name == "Phone Authentication" }
126+
if phone_auth_workflow
127+
session[:workflow_id] = phone_auth_workflow.workflow_id
113128
return session[:workflow_id]
129+
else
130+
return ""
131+
end
114132
else
115-
return None
133+
return ""
116134
end
135+
# Step 3 end
117136

118-
rescue DocuSign_Admin::ApiError => e
137+
rescue DocuSign_eSign::ApiError => e
119138
error = JSON.parse e.response_body
120139
@error_code = e.code
121140
@error_message = error['error_description']

0 commit comments

Comments
 (0)