def register_user(self): user = User(login=self.login.data, password = bcrypt.generate_password_hash(self.password.data)) try: db_session.add(user) db_session.commit() return user except: return None
def submit_challenge(challenge_id): user = current_user challenge = db_session.query(Challenge).filter_by(id=challenge_id).first() if challenge: if challenge in user.submissions: #Already solved! return "0" else: if request.form['key'] == challenge.flag: user.submissions.append(challenge) db_session.commit() return "1" else: return "0" else: abort(404)