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
@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'])
@flask_praetorian.auth_required
def survey():
@ -228,12 +239,6 @@ def survey():
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

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.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<title>BA - Marco Camenzind</title>
</head>
<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>
<!--
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 Umfrage from "./components/pages/Umfrage";
import PrivateRoute from "./auth/PrivateRoute";
import { useAuth } from "./auth/AuthProvider";
import BehaviorNormal from "./components/pages/BehaviorNormal";
function App() {
const [isLoggedIn] = useAuth();
isLoggedIn ? (document.title = isLoggedIn) : (document.title = isLoggedIn);
return (
<>
<Router>

View file

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