Allow prefilling of any fields of the login form using GET params (#181)

* Allow prefilling of any fields of the login form using GET params

* update readme
This commit is contained in:
Aine
2024-11-29 19:17:52 +02:00
committed by GitHub
parent 14d1c904c0
commit f4d0e19d21
4 changed files with 68 additions and 7 deletions

View File

@@ -171,11 +171,24 @@ const LoginPage = () => {
useEffect(() => {
const params = new URLSearchParams(window.location.search);
const hostname = window.location.hostname;
const username = params.get("username");
const password = params.get("password");
const accessToken = params.get("accessToken");
let serverURL = params.get("server");
if (username) {
form.setValue("username", username);
}
if (hostname === "localhost" || hostname === "127.0.0.1") {
if (password) {
form.setValue("password", password);
}
if (accessToken) {
setLoginMethod("accessToken");
form.setValue("accessToken", accessToken);
}
}
if (serverURL) {
const isFullUrl = serverURL.match(/^(http|https):\/\//);
if (!isFullUrl) {