Skip to content
Snippets Groups Projects
Commit 780ac0f4 authored by Anton's avatar Anton
Browse files

add logout if auth fails

parent c76b4c32
Branches
No related tags found
No related merge requests found
No preview for this file type
......@@ -279,7 +279,7 @@ def get_user_messages_by_token():
success=True, message="Messages retrieved", data=formatted_messages
)
else:
return create_response(success=False, message="You are not signed in")
return create_response(success=False, message="Authentication failed")
@app.route("/get-user-messages-by-email", methods=["GET"])
......@@ -303,7 +303,7 @@ def get_user_messages_by_email():
else:
return create_response(success=False, message="Recipient does no exist")
else:
return create_response(success=False, message="You are not signed in")
return create_response(success=False, message="Authentication failed")
@app.route("/post-message", methods=["POST"])
......@@ -328,7 +328,7 @@ def post_message():
)
return create_response(success=True, message="Message sent")
else:
return create_response(success=False, message="You are not signed in")
return create_response(success=False, message="Authentication failed")
def ws_broadcast_nr_active_user_changed():
......
......@@ -394,12 +394,7 @@ function signOut() {
window.localStorage.removeItem("token");
window.localStorage.removeItem("email");
displayView();
} else {
window.localStorage.removeItem("token");
window.localStorage.removeItem("email");
showModal("Token not valid. You have been logged out");
displayView();
}
}
};
user_identifier = localStorage.getItem("email");
......@@ -451,6 +446,12 @@ function xmlRequest(url, callback, params, token = null, requestType) {
xhttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
callback(JSON.parse(xhttp.responseText));
if (JSON.parse(xhttp.responseText).message === "Authentication failed") {
window.localStorage.removeItem("token");
window.localStorage.removeItem("email");
displayView();
showModal("Authentication failed. You must sign in again")
}
}
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment