Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix confirmation_url in user creation API
This fix will make confirmation_ur context-aware and return the proper host domain in the response. closes FOO-4343 flag=none test plan notes: - cannot test locally because distinction between environments/instances does not exist in local development - can test on cd, beta, or test - this fix is patterned after a similar fix found here: https://gerrit.instructure.com/c/canvas-lms/+/340437 test plan: - create auth token for chosen environment/instance - make POST with these key/values: user[name]:Sour Patch Ghosty pseudonym[unique_id]:spghosty pseudonym[send_confirmation]:true communication_channel[confirmation_url]:true communication_channel[type]:email communication_channel[address]:spghosty@instructure.com - in the response, confirmation_url should point to the chosen environment/instance - also, existing/modified tests should pass [skip-crystalball] [fsc-max-nodes=18] [fsc-timeout=40] Change-Id: I0e35841228c277c3d410acbcd55c65360948e748 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/344917 QA-Review: Michael Hulse <michael.hulse@instructure.com> Product-Review: Michael Hulse <michael.hulse@instructure.com> Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: August Thornton <august@instructure.com>
- Loading branch information
Showing
5 changed files
with
93 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright (C) 2024 - present Instructure, Inc. | ||
# | ||
# This file is part of Canvas. | ||
# | ||
# Canvas is free software: you can redistribute it and/or modify it under | ||
# the terms of the GNU Affero General Public License as published by the Free | ||
# Software Foundation, version 3 of the License. | ||
# | ||
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY | ||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | ||
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more | ||
# details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License along | ||
# with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
class CommunicationChannelPresenter | ||
def initialize(communication_channel, request) | ||
@communication_channel = communication_channel | ||
@request = request | ||
end | ||
|
||
def confirmation_url | ||
data = @communication_channel.confirmation_url_data | ||
return "" if incomplete_data?(data) | ||
|
||
build_url(data) | ||
end | ||
|
||
private | ||
|
||
def incomplete_data?(data) | ||
data.nil? || data[:confirmation_code].nil? | ||
end | ||
|
||
def host_url(data) | ||
# NOTE: multiple_root_accounts plugin will override HostUrl | ||
HostUrl.context_host(data[:context], @request.try(:host_with_port)) | ||
end | ||
|
||
def build_url(data) | ||
"#{HostUrl.protocol}://#{host_url(data)}/register/#{data[:confirmation_code]}" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters