def signIn(): if validLogin(request.form['loginEmail'], request.form['loginPassword']): token = createToken() result = database_helper.insertSignedInUser(token, request.form['loginEmail']); if result == True: return json.dumps({'success': True, 'message': 'Successfully signed in.', 'data': token}), 200 else: return json.dumps({'success': False, 'message': 'Could not sign in user.'}), 503 else: return json.dumps({'success': False, 'message': 'Wrong username or password.'}), 400
def signIn(): """Signs in a user and returns a token to be used for hashing.""" if validLogin(request.form['loginEmail'], request.form['loginPassword']): token = createToken() result = database_helper.insertSignedInUser(token, request.form['loginEmail']); if result == True: # Check if the user is signed in somewhere else (i.e socket is open) and if so force a logout. global webSockets if webSockets.has_key(request.form['loginEmail']): webSockets[request.form['loginEmail']].send(json.dumps({'type': 'signInStatus', 'data': 'logout'})); return json.dumps({'success': True, 'message': 'Successfully signed in.', 'data': {'token': token}}), 200 else: return json.dumps({'success': False, 'message': 'Could not sign in user.'}), 503 else: return json.dumps({'success': False, 'message': 'Wrong username or password.'}), 400