def user_register(): params = utils.flat_multi(request.form) if params.get("password") != params.get("password_confirm"): raise WebException("Passwords do not match.") verify_to_schema(UserSchema, params) name = params.get("name") email = params.get("email") username = params.get("username") password = params.get("password") password_confirm = params.get("password_confirm") utype = int(params.get("type")) register_user(name, username, email, password, utype, admin=False) login_user(username, password) logger.log( __name__, "%s registered with %s" % (name.encode("utf-8"), email.encode("utf-8"))) try: send_verification(username, email, token) except: return { "success": 1, "message": "Verification email sent to %s" % email } return {"success": 0, "message": "Failed."}
def team_create(): params = utils.flat_multi(request.form) _user = user.get_user().first() if (_user.tid is not None and _user.tid >= 0) or get_team(owner=_user.uid).first() is not None: raise WebException("You're already in a team!") verify_to_schema(TeamSchema, params) teamname = params.get("teamname") school = params.get("school") team = Teams(teamname, school, _user.uid, _user.utype != 1) with app.app_context(): db.session.add(team) db.session.commit() Users.query.filter_by(uid=_user.uid).update({ "tid": team.tid }) team_activity = UserActivity(_user.uid, 1, tid=team.tid) db.session.add(team_activity) db.session.commit() session["tid"] = team.tid return { "success": 1, "message": "Success!" }
def admin_setup(): global user params = utils.flat_multi(request.form) if utils.is_setup_complete(): raise WebException("Setup has already been complete.") if params.get("verification") != Config.query.filter_by(key="setup_verification").first().value: raise WebException("Verification does not match.") if params.get("password") != params.get("password_confirm"): raise WebException("Passwords do not match.") verify_to_schema(user.UserSchema, params) name = params.get("name") email = params.get("email") username = params.get("username") password = params.get("password") password_confirm = params.get("password_confirm") utype = int(params.get("type")) setup_vars = [ Config("ctf_name", params.get("ctf_name")), Config("start_time", params.get("start_time")), Config("end_time", params.get("end_time")), Config("team_size", params.get("team_size")), Config("stylesheet", "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"), Config("setup_complete", True) ] # _user = Users(name, username, email, password, utype=utype, admin=True) user.register_user(name, username, email, password, utype=utype, admin=True) with app.app_context(): for var in setup_vars: db.session.add(var) db.session.commit() db.session.close() logger.log(__name__, "%s registered with %s" % (name.encode("utf-8"), email.encode("utf-8"))) user.login_user(username, password) return { "success": 1, "message": "Success!" }
def team_create(): params = utils.flat_multi(request.form) _user = user.get_user().first() if (_user.tid is not None and _user.tid >= 0) or get_team( owner=_user.uid).first() is not None: raise WebException("You're already in a team!") verify_to_schema(TeamSchema, params) teamname = params.get("teamname") school = params.get("school") team = Teams(teamname, school, _user.uid, _user.utype != 1) with app.app_context(): db.session.add(team) db.session.commit() Users.query.filter_by(uid=_user.uid).update({"tid": team.tid}) team_activity = UserActivity(_user.uid, 1, tid=team.tid) db.session.add(team_activity) db.session.commit() session["tid"] = team.tid return {"success": 1, "message": "Success!"}
def user_register(): params = utils.flat_multi(request.form) if params.get("password") != params.get("password_confirm"): raise WebException("Passwords do not match.") verify_to_schema(UserSchema, params) name = params.get("name") email = params.get("email") username = params.get("username") password = params.get("password") password_confirm = params.get("password_confirm") utype = int(params.get("type")) register_user(name, username, email, password, utype, admin=False) login_user(username, password) logger.log(__name__, "%s registered with %s" % (name.encode("utf-8"), email.encode("utf-8"))) try: send_verification(request.url_root, username, email, token) except Exception, e: pass # raise WebException(str(e))
def user_register(): params = utils.flat_multi(request.form) if params.get("password") != params.get("password_confirm"): raise WebException("Passwords do not match.") verify_to_schema(UserSchema, params) name = params.get("name") email = params.get("email") username = params.get("username") password = params.get("password") password_confirm = params.get("password_confirm") utype = int(params.get("type")) register_user(name, username, email, password, utype, admin=False) login_user(username, password) logger.log(__name__, "%s registered with %s" % (name.encode("utf-8"), email.encode("utf-8"))) try: send_verification(username, email, token) except: return { "success": 1, "message": "Verification email sent to %s" % email } return { "success": 0, "message": "Failed." }