From 31513f4824e61dcd068b6d11ccdfaf287e231271 Mon Sep 17 00:00:00 2001
From: cami
Date: Fri, 23 Jul 2021 00:54:29 +0200
Subject: [PATCH 1/4] Make it not possible to copy the password with css
---
frontend/src/App.css | 1 +
1 file changed, 1 insertion(+)
diff --git a/frontend/src/App.css b/frontend/src/App.css
index b31da3c..85703b2 100644
--- a/frontend/src/App.css
+++ b/frontend/src/App.css
@@ -95,4 +95,5 @@ h1 {
.generated-password {
font-weight: bold;
+ user-select: none;
}
From 90e77bf4504cb82ea41cf9a94c90eecad3190a83 Mon Sep 17 00:00:00 2001
From: cami
Date: Fri, 23 Jul 2021 00:58:34 +0200
Subject: [PATCH 2/4] Clean up some things
---
frontend/src/components/BehaviorNormal.jsx | 1 -
frontend/src/components/GeneratedPassword.jsx | 1 -
frontend/src/components/pages/Study.jsx | 6 ++----
3 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/frontend/src/components/BehaviorNormal.jsx b/frontend/src/components/BehaviorNormal.jsx
index c427a02..9a4e715 100644
--- a/frontend/src/components/BehaviorNormal.jsx
+++ b/frontend/src/components/BehaviorNormal.jsx
@@ -10,7 +10,6 @@ export default function BehaviorNormal(props) {
Passwort eingeben. Verhalten Sie sich einfach so, als ob Sie sich
normalerweise anmelden.
- {console.log("props", props)}
>
);
diff --git a/frontend/src/components/GeneratedPassword.jsx b/frontend/src/components/GeneratedPassword.jsx
index f2b8ea9..b0920a1 100644
--- a/frontend/src/components/GeneratedPassword.jsx
+++ b/frontend/src/components/GeneratedPassword.jsx
@@ -11,7 +11,6 @@ export default function GeneratedPassword(props) {
<>
Das Passwort für diese Situation lautet:{" "}
- {console.log("component genpw, genpassword", props.genPassword)}
{props.genPassword}
>
diff --git a/frontend/src/components/pages/Study.jsx b/frontend/src/components/pages/Study.jsx
index 54b8f8b..e8588ab 100644
--- a/frontend/src/components/pages/Study.jsx
+++ b/frontend/src/components/pages/Study.jsx
@@ -73,7 +73,6 @@ export default function Study() {
const handleOnPasteEvent = (e) => {
e.preventDefault();
- console.log("paste not allowed");
return false;
};
@@ -88,7 +87,6 @@ export default function Study() {
response.json().then((resp) => {
console.log(resp.random_password);
setGenPassword(resp.random_password);
- console.log("rcv pw; print genPassword", genPassword);
});
});
};
@@ -165,7 +163,7 @@ export default function Study() {
onChange={handlePasswordChange}
InputType="password"
InputName="Passwort"
- InputPlaceHolder="Benutzername"
+ InputPlaceHolder="Passwort"
onPaste={handleOnPasteEvent}
/>
Date: Fri, 23 Jul 2021 00:59:39 +0200
Subject: [PATCH 3/4] Do not allow copy and paste in survey (fix #197)
---
frontend/src/components/GeneratedPassword.jsx | 2 +-
frontend/src/components/pages/Study.jsx | 5 ++++-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/frontend/src/components/GeneratedPassword.jsx b/frontend/src/components/GeneratedPassword.jsx
index b0920a1..1dfb3af 100644
--- a/frontend/src/components/GeneratedPassword.jsx
+++ b/frontend/src/components/GeneratedPassword.jsx
@@ -9,7 +9,7 @@ export default function GeneratedPassword(props) {
return (
<>
-
+
Das Passwort für diese Situation lautet:{" "}
{props.genPassword}
diff --git a/frontend/src/components/pages/Study.jsx b/frontend/src/components/pages/Study.jsx
index e8588ab..dec7bc3 100644
--- a/frontend/src/components/pages/Study.jsx
+++ b/frontend/src/components/pages/Study.jsx
@@ -75,6 +75,10 @@ export default function Study() {
e.preventDefault();
return false;
};
+ const handleOnCopyEvent = (e) => {
+ e.preventDefault();
+ return false;
+ };
const checkIfUsernameIsCorrect = () => {
return serverUsername === username;
@@ -96,7 +100,6 @@ export default function Study() {
};
const checkIfValuesAreCorrect = () => {
- console.log(checkIfPasswordIsCorrect());
return checkIfPasswordIsCorrect() && checkIfUsernameIsCorrect();
};
From d168b0c87ea84adcb290a62b8a644f8bc24ce6f3 Mon Sep 17 00:00:00 2001
From: cami
Date: Fri, 23 Jul 2021 01:00:14 +0200
Subject: [PATCH 4/4] Add errormessage if username or password are not correct
---
frontend/src/components/pages/Study.jsx | 42 +++++++++++++++++++------
1 file changed, 33 insertions(+), 9 deletions(-)
diff --git a/frontend/src/components/pages/Study.jsx b/frontend/src/components/pages/Study.jsx
index dec7bc3..2694809 100644
--- a/frontend/src/components/pages/Study.jsx
+++ b/frontend/src/components/pages/Study.jsx
@@ -3,6 +3,7 @@ import "../../App.css";
import Footer from "../../Footer";
import InputField from "../InputField";
import SubmitField from "../SubmitField";
+import ErrorMessage from "../ErrorMessage";
import { Logger } from "@behametrics/logger-web";
import { Button } from "../Button";
import BehaviorStudyInfo from "../BehaviorStudyInfo";
@@ -24,6 +25,10 @@ export default function Study() {
END: "end",
};
const [state, setState] = useState(STATES.START);
+ const [isInputCorrect, setIsInputCorrect] = useState(true);
+
+ const errorText =
+ "Das Passwort und der Benutzername stimmen nicht überein. Bitte prüfen Sie, dass Sie das Passwort richtig abgetippt und den Benutzernamen richtig eingegeben haben.";
useEffect(() => {
_logger.current = new Logger({
@@ -109,28 +114,44 @@ export default function Study() {
handleLoggerOn();
};
+ const resetInputValues = () => {
+ let inputElements = document.querySelectorAll('div input:not([type="submit"])');
+ for (let i=0; i < inputElements.length; i++){
+ inputElements[i].value = ""
+
+ }
+ };
+
const handleClickAtStepNormal = () => {
if (checkIfValuesAreCorrect()) {
receiveRandomPassword();
+ setIsInputCorrect(true);
setState(STATES.PHONE);
+ } else {
+ setIsInputCorrect(false);
+ resetInputValues();
}
};
const handleClickAtStepPhone = () => {
if (checkIfValuesAreCorrect()) {
receiveRandomPassword();
+ setIsInputCorrect(true);
setState(STATES.STANDING);
} else {
- console.log("Passwort und Benutzername stimmen nicht.");
+ setIsInputCorrect(false);
+ resetInputValues();
}
};
const handleClickAtStepStanding = () => {
if (checkIfValuesAreCorrect()) {
+ setIsInputCorrect(true);
setState(STATES.END);
handleLoggerOff();
} else {
- console.log("Passwort und Benutzername stimmen nicht.");
+ setIsInputCorrect(false);
+ resetInputValues();
}
};
@@ -151,8 +172,9 @@ export default function Study() {
const study_normal = (
<>
-
-