Skip to content

SSO Metadata Upload Fix #1553

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion app/components/sso-settings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ export default class SsoSettingsComponent extends Component<SsoSettingsSignature

await this.ajax.post(url, {
data: idpFormData,
contentType: 'multipart/form-data',
});

this.idpMetadataXml = null;
Expand Down
13 changes: 10 additions & 3 deletions app/services/ajax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,12 @@ export default class IreneAjaxService extends Service {
// Only include headers if _shouldSendHeaders returns true
const headers = this._shouldSendHeaders(finalUrl, options.host)
? {
'Content-Type': options.contentType || 'application/json',
// For data transfer objects we allow the browser set the content type of the request
...([FormData, Blob].some(
(dataType) => options.data instanceof dataType
)
? {}
: { 'Content-Type': options.contentType || 'application/json' }),
...this.defaultHeaders,
...options.headers,
}
Expand Down Expand Up @@ -327,11 +332,13 @@ export default class IreneAjaxService extends Service {
* @param {Response} response - The fetch response to parse.
* @returns {Promise<any | string>} - The parsed JSON or raw text.
*/
private async parseResponseText<T>(response: Response): Promise<T | string> {
private async parseResponseText<T extends object>(
response: Response
): Promise<T | string> {
const text = await response.text();

try {
return text ? JSON.parse(text) : {};
return text ? JSON.parse(text) : ({} as T);
} catch {
return text;
}
Expand Down
Loading