Update some change password things..
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing

This commit is contained in:
cami 2021-07-22 05:20:37 +02:00
parent a6346d7496
commit 58bd327377
3 changed files with 18 additions and 9 deletions

View file

@ -1,8 +1,8 @@
import React from "react"; import React from "react";
import "../App.css"; import "../App.css";
import GeneratedPassword from "./GeneratedPassword" import GeneratedPassword from "./GeneratedPassword";
export default function BehaviorNormal() { export default function BehaviorNormal(props) {
return ( return (
<> <>
<p> <p>
@ -10,7 +10,8 @@ export default function BehaviorNormal() {
Passwort eingeben. Verhalten Sie sich einfach so, als ob Sie sich Passwort eingeben. Verhalten Sie sich einfach so, als ob Sie sich
normalerweise anmelden. normalerweise anmelden.
</p> </p>
<GeneratedPassword /> {console.log("props", props)}
<GeneratedPassword genPassword={props.genPassword} />
</> </>
); );
} }

View file

@ -1,7 +1,7 @@
import React from "react"; import React from "react";
import "../App.css"; import "../App.css";
export default function GeneratedPassword() { export default function GeneratedPassword(props) {
const genPassword = "PASSWORT_MANUELL" const genPassword = "PASSWORT_MANUELL"
const handleOnCopyEvent = (e) => { const handleOnCopyEvent = (e) => {
@ -13,7 +13,8 @@ export default function GeneratedPassword() {
<> <>
<p onCopy={handleOnCopyEvent}> <p onCopy={handleOnCopyEvent}>
Das Passwort für diese Situation lautet:{" "} Das Passwort für diese Situation lautet:{" "}
<span className="generated-password">{genPassword}</span> {console.log("component genpw, genpassword", props.genPassword)}
<span className="generated-password">{props.genPassword}</span>
</p> </p>
</> </>
); );

View file

@ -83,6 +83,12 @@ export default function Study() {
}; };
const _genPassword = useRef(null); const _genPassword = useRef(null);
let genPassword = "";
const setGenPassword = (tmp) => {
genPassword = tmp;
console.log("setGenPassword", genPassword, tmp);
};
const receiveRandomPassword = () => { const receiveRandomPassword = () => {
fetch("/api/rcv_pw", { fetch("/api/rcv_pw", {
@ -90,7 +96,8 @@ export default function Study() {
}).then((response) => { }).then((response) => {
response.json().then((resp) => { response.json().then((resp) => {
_genPassword.current = resp.random_password; _genPassword.current = resp.random_password;
console.log(_genPassword.current) console.log(_genPassword.current);
setGenPassword(_genPassword.current);
}); });
}); });
}; };
@ -110,7 +117,7 @@ export default function Study() {
if (checkIfPasswordIsCorrect() && checkIfUsernameIsCorrect) { if (checkIfPasswordIsCorrect() && checkIfUsernameIsCorrect) {
return true; return true;
} else { } else {
alert("Passt nicht") alert("Passt nicht");
return false; return false;
} }
}; };
@ -158,7 +165,7 @@ export default function Study() {
const study_normal = ( const study_normal = (
<> <>
<BehaviorNormal /> <BehaviorNormal genPassword={_genPassword.current} />
<form id="behaviorNormal"> <form id="behaviorNormal">
<InputField <InputField
LabelName="Benutzername" LabelName="Benutzername"