Started implementing username and password check
This commit is contained in:
parent
e7407fd40b
commit
770e3e0285
2 changed files with 21 additions and 0 deletions
|
@ -119,6 +119,14 @@ def refresh():
|
||||||
return ret, 200
|
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')
|
@app.route('/api/protected')
|
||||||
@flask_praetorian.auth_required
|
@flask_praetorian.auth_required
|
||||||
def protected():
|
def protected():
|
||||||
|
|
|
@ -13,6 +13,7 @@ import BehaviorStudyEnd from "../BehaviorStudyEnd";
|
||||||
|
|
||||||
export default function Study() {
|
export default function Study() {
|
||||||
const _logger = useRef(0);
|
const _logger = useRef(0);
|
||||||
|
const [serverUsername, setServerUsername] = useState("");
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
_logger.current = new Logger({
|
_logger.current = new Logger({
|
||||||
|
@ -23,6 +24,13 @@ export default function Study() {
|
||||||
logToConsole: true,
|
logToConsole: true,
|
||||||
});
|
});
|
||||||
_logger.current.init();
|
_logger.current.init();
|
||||||
|
fetch("/api/username", {
|
||||||
|
method: "get",
|
||||||
|
}).then((response) => {
|
||||||
|
response.json().then((resp) => {
|
||||||
|
setServerUsername(username);
|
||||||
|
});
|
||||||
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
let username = "";
|
let username = "";
|
||||||
|
@ -64,6 +72,10 @@ export default function Study() {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const checkValuesStudy = () => {
|
||||||
|
console.log(serverUsername);
|
||||||
|
};
|
||||||
|
|
||||||
const handleClickAtStepStart = () => {
|
const handleClickAtStepStart = () => {
|
||||||
setIsStepStart(false);
|
setIsStepStart(false);
|
||||||
setIsStepNormal(true);
|
setIsStepNormal(true);
|
||||||
|
@ -71,6 +83,7 @@ export default function Study() {
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleClickAtStepNormal = () => {
|
const handleClickAtStepNormal = () => {
|
||||||
|
checkValuesStudy();
|
||||||
setIsStepNormal(false);
|
setIsStepNormal(false);
|
||||||
setIsStepPhone(true);
|
setIsStepPhone(true);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue