Add generated password to frontend
This commit is contained in:
parent
5e07b3b7dd
commit
c67da25cc9
3 changed files with 22 additions and 10 deletions
|
@ -132,12 +132,14 @@ def protected():
|
||||||
"""
|
"""
|
||||||
return {'message': f'protected endpoint (allowed user {flask_praetorian.current_user().username})'}
|
return {'message': f'protected endpoint (allowed user {flask_praetorian.current_user().username})'}
|
||||||
|
|
||||||
|
|
||||||
@app.route('/api/protected/rcv_pw', methods=['GET'])
|
@app.route('/api/protected/rcv_pw', methods=['GET'])
|
||||||
# @flask_praetorian.auth_required
|
# @flask_praetorian.auth_required
|
||||||
def get_password():
|
def get_password():
|
||||||
pw = get_random_password()
|
pw = get_random_password()
|
||||||
print(pw)
|
ret = {'password': pw}
|
||||||
return pw
|
return ret, 200
|
||||||
|
|
||||||
|
|
||||||
@app.route('/api/register', methods=['POST'])
|
@app.route('/api/register', methods=['POST'])
|
||||||
def register():
|
def register():
|
||||||
|
@ -246,8 +248,6 @@ def survey():
|
||||||
return ret, 400
|
return ret, 400
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Run the example
|
# Run the example
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run(debug=debug, host=host, port=port)
|
app.run(debug=debug, host=host, port=port)
|
||||||
|
|
|
@ -77,3 +77,7 @@ h1 {
|
||||||
.bildnachweise {
|
.bildnachweise {
|
||||||
font-size: 1.3em;
|
font-size: 1.3em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.generated-password {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import React from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import "../../App.css";
|
import "../../App.css";
|
||||||
import Footer from "../../Footer";
|
import Footer from "../../Footer";
|
||||||
import InputField from "../InputField";
|
import InputField from "../InputField";
|
||||||
|
@ -16,6 +16,8 @@ export default function BehaviorNormal() {
|
||||||
password = tmp_password;
|
password = tmp_password;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const [genPassword, setGenPassword] = useState("")
|
||||||
|
|
||||||
let logger = new Logger({
|
let logger = new Logger({
|
||||||
//inputs: ["cursor", "wheel", "keyboard", "touch"],
|
//inputs: ["cursor", "wheel", "keyboard", "touch"],
|
||||||
inputs: ["keyboard"],
|
inputs: ["keyboard"],
|
||||||
|
@ -35,24 +37,20 @@ export default function BehaviorNormal() {
|
||||||
};
|
};
|
||||||
|
|
||||||
const handlePasswordChange = (e) => {
|
const handlePasswordChange = (e) => {
|
||||||
console.log("handlePasswordChange");
|
|
||||||
setPassword(e.target.value);
|
setPassword(e.target.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleUsernameChange = (e) => {
|
const handleUsernameChange = (e) => {
|
||||||
console.log("handleUsernamechange");
|
|
||||||
setUsername(e.target.value);
|
setUsername(e.target.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleOnCopyEvent = (e) => {
|
const handleOnCopyEvent = (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
console.log("copy not allowed");
|
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleOnPasteEvent = (e) => {
|
const handleOnPasteEvent = (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
console.log("paste not allowed");
|
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -80,6 +78,16 @@ export default function BehaviorNormal() {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
fetch("/api/protected/rcv_pw", {
|
||||||
|
method: "get",
|
||||||
|
}).then((response) => {
|
||||||
|
response.json().then((resp) => {
|
||||||
|
setGenPassword(resp.password)
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="sitePage">
|
<div className="sitePage">
|
||||||
|
@ -97,7 +105,7 @@ export default function BehaviorNormal() {
|
||||||
normalerweise anmelden.
|
normalerweise anmelden.
|
||||||
</p>
|
</p>
|
||||||
<p onCopy={handleOnCopyEvent}>
|
<p onCopy={handleOnCopyEvent}>
|
||||||
Das Passwort für diese Situation lautet: abcdefgeh
|
Das Passwort für diese Situation lautet: <span className="generated-password">{genPassword}</span>
|
||||||
</p>
|
</p>
|
||||||
<form id="behaviorNormal" action="#">
|
<form id="behaviorNormal" action="#">
|
||||||
<InputField
|
<InputField
|
||||||
|
|
Loading…
Reference in a new issue