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
|
||||
|
||||
|
||||
@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():
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue