Compare commits
No commits in common. "9808c2509cad96f97eb0bc303ebb8d0bae374d4e" and "c306acc97abbbb1ed3a914831cd4decb8f9be0fc" have entirely different histories.
9808c2509c
...
c306acc97a
4 changed files with 8 additions and 87 deletions
|
@ -5,7 +5,6 @@ import flask_sqlalchemy
|
||||||
import flask_praetorian
|
import flask_praetorian
|
||||||
import flask_cors
|
import flask_cors
|
||||||
import sys
|
import sys
|
||||||
from password_util import get_random_password
|
|
||||||
|
|
||||||
db = flask_sqlalchemy.SQLAlchemy()
|
db = flask_sqlalchemy.SQLAlchemy()
|
||||||
guard = flask_praetorian.Praetorian()
|
guard = flask_praetorian.Praetorian()
|
||||||
|
@ -133,14 +132,6 @@ 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'])
|
|
||||||
# @flask_praetorian.auth_required
|
|
||||||
def get_password():
|
|
||||||
pw = get_random_password()
|
|
||||||
ret = {'password': pw}
|
|
||||||
return ret, 200
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/api/register', methods=['POST'])
|
@app.route('/api/register', methods=['POST'])
|
||||||
def register():
|
def register():
|
||||||
req = flask.request.get_json(force=True)
|
req = flask.request.get_json(force=True)
|
||||||
|
@ -248,6 +239,8 @@ 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)
|
||||||
|
|
|
@ -1,60 +0,0 @@
|
||||||
from random import seed
|
|
||||||
from random import randint
|
|
||||||
import time
|
|
||||||
|
|
||||||
seed(int(time.time()))
|
|
||||||
|
|
||||||
|
|
||||||
def get_random_value(list_length):
|
|
||||||
random_select = randint(0, list_length)
|
|
||||||
return random_select
|
|
||||||
|
|
||||||
|
|
||||||
def get_random_password():
|
|
||||||
|
|
||||||
first_part = [
|
|
||||||
"Der Vogel",
|
|
||||||
"Die Ameise",
|
|
||||||
"Die Biene",
|
|
||||||
"Ein Mensch",
|
|
||||||
"Jemand",
|
|
||||||
"Der Hund",
|
|
||||||
"Der Kater",
|
|
||||||
]
|
|
||||||
|
|
||||||
second_part = [
|
|
||||||
"frisst",
|
|
||||||
"küsst",
|
|
||||||
"begrüsst",
|
|
||||||
"besucht",
|
|
||||||
"beeinflusst",
|
|
||||||
"isst",
|
|
||||||
"findet",
|
|
||||||
"vergisst",
|
|
||||||
]
|
|
||||||
|
|
||||||
third_part = [
|
|
||||||
"den Vogel",
|
|
||||||
"die Mücke",
|
|
||||||
"den Adler",
|
|
||||||
"den Apfel",
|
|
||||||
"die Birne",
|
|
||||||
"die Biene",
|
|
||||||
"eine Gurke",
|
|
||||||
]
|
|
||||||
|
|
||||||
forth_part = [
|
|
||||||
"auf der Terasse.",
|
|
||||||
"auf der Wiese.",
|
|
||||||
"im Garten.",
|
|
||||||
"in der Kühltruhe.",
|
|
||||||
"auf dem Balkon.",
|
|
||||||
]
|
|
||||||
|
|
||||||
password = ""
|
|
||||||
password += str(first_part[get_random_value(len(first_part)-1)])
|
|
||||||
password += " " + str(second_part[get_random_value(len(second_part)-1)])
|
|
||||||
password += " " + str(third_part[get_random_value(len(third_part)-1)])
|
|
||||||
password += " " + str(forth_part[get_random_value(len(forth_part)-1)])
|
|
||||||
|
|
||||||
return password
|
|
|
@ -77,7 +77,3 @@ h1 {
|
||||||
.bildnachweise {
|
.bildnachweise {
|
||||||
font-size: 1.3em;
|
font-size: 1.3em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.generated-password {
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import React, { useEffect, useState } from "react";
|
import React 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,8 +16,6 @@ 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"],
|
||||||
|
@ -37,20 +35,24 @@ 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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -78,16 +80,6 @@ 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">
|
||||||
|
@ -105,7 +97,7 @@ export default function BehaviorNormal() {
|
||||||
normalerweise anmelden.
|
normalerweise anmelden.
|
||||||
</p>
|
</p>
|
||||||
<p onCopy={handleOnCopyEvent}>
|
<p onCopy={handleOnCopyEvent}>
|
||||||
Das Passwort für diese Situation lautet: <span className="generated-password">{genPassword}</span>
|
Das Passwort für diese Situation lautet: abcdefgeh
|
||||||
</p>
|
</p>
|
||||||
<form id="behaviorNormal" action="#">
|
<form id="behaviorNormal" action="#">
|
||||||
<InputField
|
<InputField
|
||||||
|
|
Loading…
Reference in a new issue