Skip to content

Commit db1960d

Browse files
committed
fix user creation when specifying both unique_id and path
test plan: * set the root account to have a custom "Login label" * create a user through the account new user dialog with a login id and an email * the email should be saved on the user closes #CNVS-36237 Change-Id: Ifd5d12ee9b78e37a886d0dd66f54f05f2223387a Reviewed-on: https://gerrit.instructure.com/108305 Tested-by: Jenkins Reviewed-by: Simon Williams <simon@instructure.com> QA-Review: Deepeeca Soundarrajan <dsoundarrajan@instructure.com> Product-Review: James Williams <jamesw@instructure.com>
1 parent 6c75c62 commit db1960d

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

app/controllers/users_controller.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2285,9 +2285,10 @@ def create_user
22852285
includes << 'confirmation_url' if value_to_boolean(cc_params[:confirmation_url])
22862286
end
22872287

2288-
elsif EmailAddressValidator.valid?(params[:pseudonym][:unique_id])
2288+
else
22892289
cc_type = CommunicationChannel::TYPE_EMAIL
22902290
cc_addr = params[:pseudonym].delete(:path) || params[:pseudonym][:unique_id]
2291+
cc_addr = nil unless EmailAddressValidator.valid?(cc_addr)
22912292
end
22922293

22932294
if params[:user]

spec/controllers/users_controller_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,12 @@
519519
expect(p.user).to be_pre_registered
520520
end
521521

522+
it "should create users with non-email pseudonyms and an email" do
523+
post 'create', format: 'json', account_id: account.id, pseudonym: { unique_id: 'testid', path: 'testemail@example.com' }, user: { name: 'test' }
524+
expect(response).to be_success
525+
p = Pseudonym.where(unique_id: 'testid').first
526+
expect(p.user.email).to eq "testemail@example.com"
527+
end
522528

523529
it "should not require acceptance of the terms" do
524530
post 'create', :account_id => account.id, :pseudonym => { :unique_id => 'jacob@instructure.com' }, :user => { :name => 'Jacob Fugal' }

0 commit comments

Comments
 (0)