Added login feedback in the backend
This commit is contained in:
parent
d073c8ea2e
commit
160e4d936e
2 changed files with 8 additions and 4 deletions
|
@ -98,9 +98,13 @@ def login():
|
||||||
req = flask.request.get_json(force=True)
|
req = flask.request.get_json(force=True)
|
||||||
username = req.get('username', None)
|
username = req.get('username', None)
|
||||||
password = req.get('password', None)
|
password = req.get('password', None)
|
||||||
|
try:
|
||||||
user = guard.authenticate(username, password)
|
user = guard.authenticate(username, password)
|
||||||
ret = {'access_token': guard.encode_jwt_token(user)}
|
ret = {'access_token': guard.encode_jwt_token(user)}
|
||||||
return ret, 200
|
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'])
|
@app.route('/api/refresh', methods=['POST'])
|
||||||
|
|
|
@ -17,7 +17,6 @@ export default function Login() {
|
||||||
username: username,
|
username: username,
|
||||||
password: password,
|
password: password,
|
||||||
};
|
};
|
||||||
console.log(opts);
|
|
||||||
fetch("/api/login", {
|
fetch("/api/login", {
|
||||||
method: "post",
|
method: "post",
|
||||||
body: JSON.stringify(opts),
|
body: JSON.stringify(opts),
|
||||||
|
@ -27,6 +26,7 @@ export default function Login() {
|
||||||
if (token.access_token) {
|
if (token.access_token) {
|
||||||
login(token);
|
login(token);
|
||||||
} else {
|
} else {
|
||||||
|
// TODO: add text if the login is not correct
|
||||||
console.log("Please type in the correct username / password");
|
console.log("Please type in the correct username / password");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue