diff --git a/.prettierrc b/.prettierrc
index 17335ee..c3c0ee3 100644
--- a/.prettierrc
+++ b/.prettierrc
@@ -6,6 +6,5 @@
"singleQuote": false,
"trailingComma": "es5",
"bracketSpacing": true,
- "jsxBracketSameLine": false,
- "arrowParens": "avoid",
+ "jsxBracketSameLine": false
}
diff --git a/package.json b/package.json
index 7d754fe..0d49bed 100644
--- a/package.json
+++ b/package.json
@@ -4,29 +4,28 @@
"description": "Admin GUI for the Matrix.org server Synapse",
"author": "Awesome Technologies Innovationslabor GmbH",
"license": "Apache-2.0",
- "homepage": ".",
"repository": {
"type": "git",
"url": "https://github.com/Awesome-Technologies/synapse-admin"
},
"devDependencies": {
"@testing-library/jest-dom": "^5.1.1",
- "@testing-library/react": "^10.0.2",
- "@testing-library/user-event": "^10.0.1",
+ "@testing-library/react": "^9.4.0",
+ "@testing-library/user-event": "^8.1.0",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.2",
"eslint": "^6.8.0",
- "eslint-config-prettier": "^6.10.1",
+ "eslint-config-prettier": "^6.10.0",
"eslint-plugin-prettier": "^3.1.2",
- "prettier": "^2.0.0"
+ "prettier": "^1.19.1"
},
"dependencies": {
"prop-types": "^15.7.2",
"ra-language-german": "^2.1.2",
- "react": "^16.13.1",
- "react-admin": "^3.4.0",
- "react-dom": "^16.13.1",
- "react-scripts": "^3.4.1"
+ "react": "^16.12.0",
+ "react-admin": "^3.1.3",
+ "react-dom": "^16.12.0",
+ "react-scripts": "^3.3.0"
},
"scripts": {
"start": "react-scripts start",
diff --git a/src/App.js b/src/App.js
index 238d13b..ce37344 100644
--- a/src/App.js
+++ b/src/App.js
@@ -36,7 +36,6 @@ const App = () => (
icon={UserIcon}
/>
-
);
diff --git a/src/components/LoginPage.js b/src/components/LoginPage.js
index 984300b..19280b3 100644
--- a/src/components/LoginPage.js
+++ b/src/components/LoginPage.js
@@ -1,17 +1,13 @@
import React, { useState } from "react";
import {
- fetchUtils,
- FormDataConsumer,
Notification,
useLogin,
useNotify,
useLocale,
useSetLocale,
useTranslate,
- PasswordInput,
- TextInput,
} from "react-admin";
-import { Form, useForm } from "react-final-form";
+import { Field, Form } from "react-final-form";
import {
Avatar,
Button,
@@ -38,7 +34,7 @@ const useStyles = makeStyles(theme => ({
backgroundSize: "cover",
},
card: {
- minWidth: "30em",
+ minWidth: 300,
marginTop: "6em",
},
avatar: {
@@ -74,7 +70,7 @@ const LoginPage = ({ theme }) => {
var locale = useLocale();
const setLocale = useSetLocale();
const translate = useTranslate();
- const base_url = localStorage.getItem("base_url");
+ const homeserver = localStorage.getItem("base_url");
const renderInput = ({
meta: { touched, error } = {},
@@ -92,21 +88,15 @@ const LoginPage = ({ theme }) => {
const validate = values => {
const errors = {};
+ if (!values.homeserver) {
+ errors.homeserver = translate("ra.validation.required");
+ }
if (!values.username) {
errors.username = translate("ra.validation.required");
}
if (!values.password) {
errors.password = translate("ra.validation.required");
}
- if (!values.base_url) {
- errors.base_url = translate("ra.validation.required");
- } else {
- if (!values.base_url.match(/^(http|https):\/\//)) {
- errors.base_url = translate("synapseadmin.auth.protocol_error");
- } else if (!values.base_url.match(/^(http|https):\/\/[a-zA-Z0-9\-.]+$/)) {
- errors.base_url = translate("synapseadmin.auth.url_error");
- }
- }
return errors;
};
@@ -125,75 +115,9 @@ const LoginPage = ({ theme }) => {
});
};
- const extractHomeServer = username => {
- const usernameRegex = /@[a-zA-Z0-9._=\-/]+:([a-zA-Z0-9\-.]+\.[a-zA-Z]+)/;
- if (!username) return null;
- const res = username.match(usernameRegex);
- if (res) return res[1];
- return null;
- };
-
- const UserData = ({ formData }) => {
- const form = useForm();
-
- const handleUsernameChange = _ => {
- if (formData.base_url) return;
- // check if username is a full qualified userId then set base_url accordially
- const home_server = extractHomeServer(formData.username);
- const wellKnownUrl = `https://${home_server}/.well-known/matrix/client`;
- if (home_server) {
- // fetch .well-known entry to get base_url
- fetchUtils
- .fetchJson(wellKnownUrl, { method: "GET" })
- .then(({ json }) => {
- form.change("base_url", json["m.homeserver"].base_url);
- })
- .catch(_ => {
- // if there is no .well-known entry, try the home server name
- form.change("base_url", `https://${home_server}`);
- });
- }
- };
-
- return (
-
- );
- };
-
return (