Password validation works but password is not shown in generated password thing
This commit is contained in:
parent
c1fce5bf4a
commit
a6346d7496
2 changed files with 37 additions and 18 deletions
|
@ -70,36 +70,64 @@ export default function Study() {
|
|||
|
||||
const handleOnPasteEvent = (e) => {
|
||||
e.preventDefault();
|
||||
console.log("paste not allowed");
|
||||
return false;
|
||||
};
|
||||
|
||||
const checkIfUsernameIsCorrect = () => {
|
||||
console.log("serverUsername", serverUsername);
|
||||
console.log("username", username);
|
||||
if (serverUsername === username) {
|
||||
console.log("Passt soweit");
|
||||
return true;
|
||||
} else {
|
||||
console.log("Passt gar nicht");
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
const _genPassword = useRef(null);
|
||||
|
||||
const receiveRandomPassword = () => {
|
||||
fetch("/api/rcv_pw", {
|
||||
method: "get",
|
||||
}).then((response) => {
|
||||
response.json().then((resp) => {
|
||||
_genPassword.current = resp.random_password;
|
||||
console.log(_genPassword.current)
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const checkIfPasswordIsCorrect = () => {
|
||||
if (_genPassword.current === password) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
const checkIfValuesAreCorrect = () => {
|
||||
checkIfUsernameIsCorrect();
|
||||
checkIfPasswordIsCorrect();
|
||||
console.log(checkIfPasswordIsCorrect());
|
||||
if (checkIfPasswordIsCorrect() && checkIfUsernameIsCorrect) {
|
||||
return true;
|
||||
} else {
|
||||
alert("Passt nicht")
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
const handleClickAtStepStart = () => {
|
||||
setIsStepStart(false);
|
||||
setIsStepNormal(true);
|
||||
handleLoggerOn();
|
||||
receiveRandomPassword();
|
||||
};
|
||||
|
||||
const handleClickAtStepNormal = () => {
|
||||
checkIfValuesAreCorrect();
|
||||
setIsStepNormal(false);
|
||||
setIsStepPhone(true);
|
||||
if (checkIfValuesAreCorrect()){
|
||||
receiveRandomPassword();
|
||||
setIsStepNormal(false);
|
||||
setIsStepPhone(true);
|
||||
}
|
||||
};
|
||||
|
||||
const handleClickAtStepPhone = () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue