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)
|
||||
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'])
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue