Updated some things and logger starts only once #158

Merged
cami merged 1 commit from update/fix-some-things into main 2021-07-16 00:20:10 +00:00
9 changed files with 36 additions and 27 deletions

View file

@ -157,6 +157,17 @@ def register():
return ret, 409 return ret, 409
@app.route('/api/protected/behavior', methods=['POST'])
@flask_praetorian.auth_required
def check_password_username():
req = flask.request.get_json(force=True)
token = guard.read_token_from_header()
extracted_token = guard.extract_jwt_token(token)
id_req = extracted_token['id']
ret = {'message': 'Top'}
return ret, 200
@app.route('/api/protected/umfrage', methods=['POST']) @app.route('/api/protected/umfrage', methods=['POST'])
@flask_praetorian.auth_required @flask_praetorian.auth_required
def survey(): def survey():
@ -228,12 +239,6 @@ def survey():
return ret, 400 return ret, 400
@app.route('/api/protected/behavior', methods=['POST'])
@flask_praetorian.auth_required
def check_password_username():
print("hallooo POST", file=sys.stderr)
ret = {'message': 'Top'}
return ret, 200
# Run the example # Run the example

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View file

@ -28,10 +28,10 @@
work correctly both with client-side routing and a non-root public URL. work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`. Learn how to configure a non-root public URL by running `npm run build`.
--> -->
<title>React App</title> <title>BA - Marco Camenzind</title>
</head> </head>
<body> <body>
<noscript>You need to enable JavaScript to run this app.</noscript> <noscript>Diese Anwendung funktioniert leider nur mit JavaScript. Bitte aktivieren JavaScript in den Einstellungen</noscript>
<div id="root"></div> <div id="root"></div>
<!-- <!--
This HTML file is a template. This HTML file is a template.

View file

@ -12,12 +12,9 @@ import Manual from "./components/pages/Manual";
import Secret from "./components/pages/Secret"; import Secret from "./components/pages/Secret";
import Umfrage from "./components/pages/Umfrage"; import Umfrage from "./components/pages/Umfrage";
import PrivateRoute from "./auth/PrivateRoute"; import PrivateRoute from "./auth/PrivateRoute";
import { useAuth } from "./auth/AuthProvider";
import BehaviorNormal from "./components/pages/BehaviorNormal"; import BehaviorNormal from "./components/pages/BehaviorNormal";
function App() { function App() {
const [isLoggedIn] = useAuth();
isLoggedIn ? (document.title = isLoggedIn) : (document.title = isLoggedIn);
return ( return (
<> <>
<Router> <Router>

View file

@ -6,6 +6,7 @@ import "@fortawesome/fontawesome-free/css/all.css";
function Navbar() { function Navbar() {
const [click, setClick] = useState(false); const [click, setClick] = useState(false);
// eslint-disable-next-line
const [button, setButton] = useState(true); const [button, setButton] = useState(true);
const handleClick = () => setClick(!click); const handleClick = () => setClick(!click);

View file

@ -1,15 +1,17 @@
import React, { useEffect, useState } from "react"; import React, { useState, useEffect } from "react";
import "../../App.css"; import "../../App.css";
import Footer from "../../Footer"; import Footer from "../../Footer";
import { Logger } from "@behametrics/logger-web"; import { logout, useAuth } from "../../auth/AuthProvider";
import { useAuth } from "../../auth/AuthProvider";
import InputField from "../InputField"; import InputField from "../InputField";
import SubmitField from "../SubmitField"; import SubmitField from "../SubmitField";
import { Logger } from "@behametrics/logger-web";
export default function BehaviorNormal() { export default function BehaviorNormal() {
const [username, setUsername] = useState(""); const [username, setUsername] = useState("");
const [password, setPassword] = useState(""); const [password, setPassword] = useState("");
const [isLoggedIn] = useAuth();
const handleUsernameChange = (e) => { const handleUsernameChange = (e) => {
setUsername(e.target.value); setUsername(e.target.value);
}; };
@ -39,6 +41,8 @@ export default function BehaviorNormal() {
method: "post", method: "post",
body: JSON.stringify(opts), body: JSON.stringify(opts),
}).then((response) => { }).then((response) => {
console.log(response.status);
console.log(isLoggedIn);
if (response.status === 401) { if (response.status === 401) {
response.json().then((resp) => { response.json().then((resp) => {
console.log("nicht so wirklich gut"); console.log("nicht so wirklich gut");
@ -55,20 +59,20 @@ export default function BehaviorNormal() {
let logger = new Logger({ let logger = new Logger({
//inputs: ["cursor", "wheel", "keyboard", "touch"], //inputs: ["cursor", "wheel", "keyboard", "touch"],
inputs: ["keyboard"], inputs: ["keyboard"],
// logToConsole: true, logToConsole: true,
}); });
logger.init();
let [isLoggedIn] = useAuth(); const handleOff = () => {
logger.stop();
logout();
console.log("Logger ausgeschaltet");
};
useEffect(() => { useEffect(() => {
document.title = `${isLoggedIn}`; logger.init().then(() => logger.start());
if (isLoggedIn === false) { console.log("start logging");
logger.stop(); }, []);
} else {
logger.start();
}
});
return ( return (
<> <>
<div className="sitePage"> <div className="sitePage">
@ -87,7 +91,7 @@ export default function BehaviorNormal() {
<p onCopy={handleOnCopyEvent}> <p onCopy={handleOnCopyEvent}>
Das Passwort für diese Situation lautet: abcdefgeh Das Passwort für diese Situation lautet: abcdefgeh
</p> </p>
<form action="#"> <form id="behaviorNormal" action="#">
<InputField <InputField
LabelName="Benutzername" LabelName="Benutzername"
onChange={handleUsernameChange} onChange={handleUsernameChange}
@ -107,12 +111,14 @@ export default function BehaviorNormal() {
onPaste={handleOnPasteEvent} onPaste={handleOnPasteEvent}
/> />
<SubmitField <SubmitField
LabelName="Weiter zur nächsten Situation" LabelNa
me="Weiter zur nächsten Situation"
InputValue="next-situation" InputValue="next-situation"
InputName="Weiter" InputName="Weiter"
onClick={onSubmitClick} onClick={onSubmitClick}
/> />
</form> </form>
<button onClick={handleOff}>STOP THAT FUCKING LOGGER</button>
</div> </div>
<Footer /> <Footer />
</> </>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 466 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 612 KiB

View file

@ -1,6 +1,6 @@
podman stop frontend-dev frontend-prod frontend-testing backend-dev backend-prod backend-testing podman stop frontend-dev frontend-prod frontend-testing backend-dev backend-prod backend-testing
podman rm frontend-dev frontend-prod frontend-testing backend-dev backend-prod backend-testing podman rm frontend-dev frontend-prod frontend-testing backend-dev backend-prod backend-testing
podman rmi {frontend,backend}-testing podman rmi app_from_scratch_backend-dev app_from_scratch_frontend-dev
podman rmi caminsha/bt-frontend caminsha/bt-backend podman rmi caminsha/bt-frontend caminsha/bt-backend
podman-compose down podman-compose down
podman-compose -f docker-compose.prod.yml down podman-compose -f docker-compose.prod.yml down