def check_auth(username, password): """This function is called to check if a username / password combination is valid. """ user=User.get_by(email_address=username) if user == None: return False if md5(password).hexdigest() != user.hash: return False return True
def get_conversations_hardcoded(): password = "******" hash = md5(password).hexdigest() user_one = User.get_by(email_address="*****@*****.**") or \ User(email_address="*****@*****.**", name="Bob", hash=hash) user_two = User.get_by(email_address="*****@*****.**") or \ User(email_address="*****@*****.**", name="Jane", hash=hash) entries = [ ConversationEntry(user=user_one, text="KILL ALL UNICORNS!!!1111", time=datetime.now()), ConversationEntry(user=user_two, text="NNNooooooooooo", time=datetime.now()) ] participants = [ ConversationParticipant(user=user_one, stance="KILL ALL UNICORNS"), ConversationParticipant(user=user_two, stance="SAVE THE UNICORNS"), ] question_text = "Should unicorn hunting be outlawed?" question = Question.get_by(text=question_text) or Question(text=question_text, topic="Conservation") conversation = Conversation( votes=[], entries=entries, participaints=participants, question=question) return flask.jsonify({"conversations": [conversation.to_json()]}), 200