Skip to content
Snippets Groups Projects
Commit dd07b92b authored by Lawrence Zawahri's avatar Lawrence Zawahri
Browse files

lab 3 working on bug ficx

parent cd7927bc
No related branches found
No related tags found
No related merge requests found
......@@ -85,19 +85,36 @@ def echo(socket):
return
# sign out if I am logged in somewhere else
print("Before loop")
print("/n")
print(session)
print("/n")
for token in list(session.keys()):
if session[token][0] == myEmail and token != myToken:
if session[token][1] != "":
session[token][1].send(json.dumps({"action" : "signOut"}))
session[token][1].close()
if session[token][0] == myEmail and token != myToken and session[token][1] != "":
print("Inside first if")
#if session[token][1] != "":
print("Inside second if")
session[token][1].send(json.dumps({"action" : "signOut"}))
print(token[1])
session[token][1].close()
print("You got kicked out")
session.pop(token)
print("After loop")
print("/n")
print(session)
print("/n")
# Put socket in global dict so server knows my connection is open
session[myToken] = (myEmail, socket)
print("After insertion into dict")
print("/n")
print(session)
print("/n")
socket.send(json.dumps({"action" : "signIn"}))
......@@ -123,7 +140,7 @@ def sign_in():
return jsonify({}), 404 #"No user found by your email"
if password != rows[1]:
return jsonify({}), 401 #"Incorrect password")
return jsonify({}), 401 #"Incorrect password") x
# Generate a random token
token = str(uuid.uuid4())
......
......@@ -17,7 +17,6 @@ function connectWithSocket() {
displayView();
setUserDetails("home");
// Establish web socket
socket = new WebSocket('ws://' + document.domain + ':5000/myServer/api');
......@@ -37,7 +36,7 @@ function connectWithSocket() {
case "signOut":
// If old socket open, close it.
socket.close();
//socket.close();
console.log(response);
// Reset token in the localStorage
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment