Added login feedback in the backend [fix #98] #99

Merged
cami merged 2 commits from login/feedback into main 2021-07-04 22:03:24 +00:00
2 changed files with 8 additions and 4 deletions
Showing only changes of commit 160e4d936e - Show all commits

View file

@ -98,9 +98,13 @@ def login():
req = flask.request.get_json(force=True)
username = req.get('username', None)
password = req.get('password', None)
user = guard.authenticate(username, password)
ret = {'access_token': guard.encode_jwt_token(user)}
return ret, 200
try:
user = guard.authenticate(username, password)
ret = {'access_token': guard.encode_jwt_token(user)}
return ret, 200
except flask_praetorian.exceptions.AuthenticationError:
ret = {'message': "Benutzername und Passwort stimmen nicht überein"}
return ret, 401
@app.route('/api/refresh', methods=['POST'])

View file

@ -17,7 +17,6 @@ export default function Login() {
username: username,
password: password,
};
console.log(opts);
fetch("/api/login", {
method: "post",
body: JSON.stringify(opts),
@ -27,6 +26,7 @@ export default function Login() {
if (token.access_token) {
login(token);
} else {
// TODO: add text if the login is not correct
console.log("Please type in the correct username / password");
}
});