Check in the frontend if the username and password in the survey are correct (fix #179) #185

Merged
cami merged 12 commits from frontend/check-username-pw-survey into main 2021-07-22 14:55:27 +00:00
2 changed files with 21 additions and 0 deletions
Showing only changes of commit 770e3e0285 - Show all commits

View file

@ -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():

View file

@ -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);
};