Check if username is the same as in the current session
This commit is contained in:
parent
770e3e0285
commit
130088756d
2 changed files with 23 additions and 9 deletions
|
@ -122,9 +122,9 @@ def refresh():
|
||||||
@app.route('/api/username', methods=['GET'])
|
@app.route('/api/username', methods=['GET'])
|
||||||
@flask_praetorian.auth_required
|
@flask_praetorian.auth_required
|
||||||
def get_username():
|
def get_username():
|
||||||
user = flask_praetorian.current_user().username
|
username = flask_praetorian.current_user().username
|
||||||
ret = {'username': user}
|
ret = {'username': username}
|
||||||
return user, 200
|
return ret, 200
|
||||||
|
|
||||||
|
|
||||||
@app.route('/api/protected')
|
@app.route('/api/protected')
|
||||||
|
|
|
@ -4,12 +4,13 @@ import Footer from "../../Footer";
|
||||||
import InputField from "../InputField";
|
import InputField from "../InputField";
|
||||||
import SubmitField from "../SubmitField";
|
import SubmitField from "../SubmitField";
|
||||||
import { Logger } from "@behametrics/logger-web";
|
import { Logger } from "@behametrics/logger-web";
|
||||||
|
import { Button } from "../Button";
|
||||||
import BehaviorStudyInfo from "../BehaviorStudyInfo";
|
import BehaviorStudyInfo from "../BehaviorStudyInfo";
|
||||||
import BehaviorNormal from "../BehaviorNormal";
|
import BehaviorNormal from "../BehaviorNormal";
|
||||||
import { Button } from "../Button";
|
|
||||||
import BehaviorPhone from "../BehaviorPhone";
|
import BehaviorPhone from "../BehaviorPhone";
|
||||||
import BehaviorStanding from "../BehaviorStanding";
|
import BehaviorStanding from "../BehaviorStanding";
|
||||||
import BehaviorStudyEnd from "../BehaviorStudyEnd";
|
import BehaviorStudyEnd from "../BehaviorStudyEnd";
|
||||||
|
import { authFetch } from "../../auth/AuthProvider";
|
||||||
|
|
||||||
export default function Study() {
|
export default function Study() {
|
||||||
const _logger = useRef(0);
|
const _logger = useRef(0);
|
||||||
|
@ -24,11 +25,11 @@ export default function Study() {
|
||||||
logToConsole: true,
|
logToConsole: true,
|
||||||
});
|
});
|
||||||
_logger.current.init();
|
_logger.current.init();
|
||||||
fetch("/api/username", {
|
authFetch("/api/username", {
|
||||||
method: "get",
|
method: "get",
|
||||||
}).then((response) => {
|
}).then((response) => {
|
||||||
response.json().then((resp) => {
|
response.json().then((resp) => {
|
||||||
setServerUsername(username);
|
setServerUsername(resp.username);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
@ -72,8 +73,21 @@ export default function Study() {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const checkValuesStudy = () => {
|
const checkIfUsernameIsCorrect = () => {
|
||||||
console.log(serverUsername);
|
console.log("serverUsername", serverUsername);
|
||||||
|
console.log("username", username);
|
||||||
|
if (serverUsername === username) {
|
||||||
|
console.log("Passt soweit");
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
console.log("Passt gar nicht");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const checkIfValuesAreCorrect = () => {
|
||||||
|
checkIfUsernameIsCorrect();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleClickAtStepStart = () => {
|
const handleClickAtStepStart = () => {
|
||||||
|
@ -83,7 +97,7 @@ export default function Study() {
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleClickAtStepNormal = () => {
|
const handleClickAtStepNormal = () => {
|
||||||
checkValuesStudy();
|
checkIfValuesAreCorrect();
|
||||||
setIsStepNormal(false);
|
setIsStepNormal(false);
|
||||||
setIsStepPhone(true);
|
setIsStepPhone(true);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue