diff --git a/backend/src/app.py b/backend/src/app.py index 62be6d7..700dd2b 100644 --- a/backend/src/app.py +++ b/backend/src/app.py @@ -119,6 +119,14 @@ def refresh(): return ret, 200 +@app.route('/api/username', methods=['GET']) +@flask_praetorian.auth_required +def get_username(): + user = flask_praetorian.current_user().username + ret = {'username': user} + return user, 200 + + @app.route('/api/protected') @flask_praetorian.auth_required def protected(): diff --git a/frontend/src/components/pages/Study.js b/frontend/src/components/pages/Study.js index c5247c9..2f7b689 100644 --- a/frontend/src/components/pages/Study.js +++ b/frontend/src/components/pages/Study.js @@ -13,6 +13,7 @@ import BehaviorStudyEnd from "../BehaviorStudyEnd"; export default function Study() { const _logger = useRef(0); + const [serverUsername, setServerUsername] = useState(""); useEffect(() => { _logger.current = new Logger({ @@ -23,6 +24,13 @@ export default function Study() { logToConsole: true, }); _logger.current.init(); + fetch("/api/username", { + method: "get", + }).then((response) => { + response.json().then((resp) => { + setServerUsername(username); + }); + }); }, []); let username = ""; @@ -64,6 +72,10 @@ export default function Study() { return false; }; + const checkValuesStudy = () => { + console.log(serverUsername); + }; + const handleClickAtStepStart = () => { setIsStepStart(false); setIsStepNormal(true); @@ -71,6 +83,7 @@ export default function Study() { }; const handleClickAtStepNormal = () => { + checkValuesStudy(); setIsStepNormal(false); setIsStepPhone(true); };