Validate URL on input instead of automatic rewrite of http to https
Change-Id: I3f3a9c5fb408af1f03ef876456133b331dc4cea3
This commit is contained in:
committed by
Manuel Stahl
parent
437fd70d6d
commit
dd022eab04
@@ -1,13 +1,5 @@
|
||||
import { fetchUtils } from "react-admin";
|
||||
|
||||
const ensureHttpsForUrl = url => {
|
||||
if (/^https:\/\//i.test(url)) {
|
||||
return url;
|
||||
}
|
||||
const domain = url.replace(/http.?:\/\//g, "");
|
||||
return "https://" + domain;
|
||||
};
|
||||
|
||||
const stripTrailingSlash = str => {
|
||||
if (!str) {
|
||||
return;
|
||||
@@ -17,7 +9,7 @@ const stripTrailingSlash = str => {
|
||||
|
||||
const authProvider = {
|
||||
// called when the user attempts to log in
|
||||
login: ({ homeserver, username, password }) => {
|
||||
login: ({ base_url, username, password }) => {
|
||||
console.log("login ");
|
||||
const options = {
|
||||
method: "POST",
|
||||
@@ -28,10 +20,8 @@ const authProvider = {
|
||||
}),
|
||||
};
|
||||
|
||||
const url = window.decodeURIComponent(homeserver);
|
||||
const trimmed_url = url.trim().replace(/\s/g, "");
|
||||
const login_api_url =
|
||||
ensureHttpsForUrl(trimmed_url) + "/_matrix/client/r0/login";
|
||||
const decoded_base_url = window.decodeURIComponent(base_url);
|
||||
const login_api_url = decoded_base_url + "/_matrix/client/r0/login";
|
||||
|
||||
return fetchUtils.fetchJson(login_api_url, options).then(({ json }) => {
|
||||
const normalized_base_url = stripTrailingSlash(
|
||||
|
||||
Reference in New Issue
Block a user