コード例 #1
0
ファイル: account.py プロジェクト: zachriggle/CTF-Platform
def register_team(request):
    """Register a new team.

    Checks that an email address, team name, adviser name, affiliation, and password were sent from the browser.
    If any of these are missing a status:0 is returned with a message saying that all fields must be provided.
    Verifies that no teams exist with the specified name, if one exists a status:0 with a message is returned.
    If the 'joingroup' flag is empty or false and the passed 'group' is not empty we check to see if a group with that
    name exists in the database, if it does we return a status:2 and a message saying the the group exists, and give
    the user the option to join it.
    If no failure at this point the function hashes the password and inserts the data into a new db document
    in the teams collection.
    If the passed 'group' was empty we now return a status:1 with a successful registration message. If the 'joingroup'
    flag was set/true (and 'group' exists) we search for the group, if it does NOT exist we create it and add the new
    team as an owner and member.  If it does exist we add the team as a member of the group.
    If 'joingroup' is not set/false but 'group' exists then we create the new group and add the user as an owner/member,
    we already know that the group does not exist (would have been caught at the beginning).
    """
    email = request.form.get('email', '')
    teamname = request.form.get('teamname', '')
    adviser = request.form.get('name', '')
    affiliation = request.form.get('aff', '')
    pwd = request.form.get('password', '')
    gname = request.form.get('group', '').lower().strip('')
    joingroup = 'true' #request.form.get('joingroup', '')
    print {email, teamname, pwd}
    if '' in {email, teamname, pwd}:
        return {'success': 0, 'message': "Please fill in all of the required fields."}
    if db.teams.find({'teamname': teamname}).count() != 0:
        return {'success': 0, 'message': "That team name is already registered."}
    # if joingroup != 'true' and gname != '':
        # if db.groups.find({'name': gname}).count() != 0:
            # return {'success': 2, 'message': "The group name you have entered exists, would you like to join it?"}

    tid = common.token()
    db.teams.insert({'email': str(email),
                     'advisor': str(adviser),
                     'teamname': str(teamname),
                     'affiliation': str(affiliation),
                     'pwhash': bcrypt.hashpw(str(pwd), bcrypt.gensalt(8)),
                     'tid': tid})
    if gname == '':
        return {'success': 1, 'message': "Success! You have successfully registered."}

    if joingroup == 'true':
        if db.groups.find({'name': gname}).count() == 0:
            group.create_group(tid, gname)
        else:
            db.groups.update({'name': gname}, {'$push': {'members': tid}})
            return {'success': 1, 'message': 'Success! You have been added to the group!'}
    else:
        group.create_group(tid, gname)
        return {'success': 1, 'message': "Success! You are registered and have created your group."}
コード例 #2
0
ファイル: account.py プロジェクト: IMSA-ACA/aurora-platform
def register_team(request):
    """Register a new team.

    Checks that an email address, team name, adviser name, affiliation, and password were sent from the browser.
    If any of these are missing a status:0 is returned with a message saying that all fields must be provided.
    Verifies that no teams exist with the specified name, if one exists a status:0 with a message is returned.
    If the 'joingroup' flag is empty or false and the passed 'group' is not empty we check to see if a group with that
    name exists in the database, if it does we return a status:2 and a message saying the the group exists, and give
    the user the option to join it.
    If no failure at this point the function hashes the password and inserts the data into a new db document
    in the teams collection.
    If the passed 'group' was empty we now return a status:1 with a successful registration message. If the 'joingroup'
    flag was set/true (and 'group' exists) we search for the group, if it does NOT exist we create it and add the new
    team as an owner and member.  If it does exist we add the team as a member of the group.
    If 'joingroup' is not set/false but 'group' exists then we create the new group and add the user as an owner/member,
    we already know that the group does not exist (would have been caught at the beginning).
    """
    email = request.form.get('email', '')
    teamname = request.form.get('team', '')
    adviser = request.form.get('name', '')
    affiliation = request.form.get('aff', '')
    pwd = request.form.get('pass', '')
    gname = request.form.get('group', '').lower().strip('')
    joingroup = request.form.get('joingroup', '')

    if '' in {email, teamname, adviser, affiliation, pwd}:
        return {'status': 0, 'message': "Please fill in all of the required fields."}
    if db.teams.find({'teamname': teamname}).count() != 0:
        return {'status': 0, 'message': "That team name is already registered."}
    if joingroup != 'true' and gname != '':
        if db.groups.find({'name': gname}).count() != 0:
            return {'status': 2, 'message': "The group name you have entered exists, would you like to join it?"}

    tid = common.token()
    db.teams.insert({'email': str(email),
                     'advisor': str(adviser),
                     'teamname': str(teamname),
                     'affiliation': str(affiliation),
                     'pwhash': bcrypt.hashpw(str(pwd), bcrypt.gensalt(8)),
                     'tid': tid})
    if gname == '':
        return {'status': 1, 'message': "Success! You have successfully registered."}

    if joingroup == 'true':
        if db.groups.find({'name': gname}).count() == 0:
            group.create_group(tid, gname)
        else:
            db.groups.update({'name': gname}, {'$push': {'members': tid}})
            return {'status': 1, 'message': 'Success! You have been added to the group!'}
    else:
        group.create_group(tid, gname)
        return {'status': 1, 'message': "Success! You are registered and have created your group."}
コード例 #3
0
ファイル: main.py プロジェクト: Hot-key/Notifications
def new_group_handler(request):
    group_name = request & get_arg('group_name')
    invite_key = request & get_arg('group_invite_key')
    new_group = (create_group(group_name, invite_key) &
                 (lambda x: GroupManager().add_new_group(x)))
    result = new_group.attempt() & aduit_flow
    return result
コード例 #4
0
def create_group_hook():
    return group.create_group(session['tid'], request.form.get('name', ''))
コード例 #5
0
ファイル: router.py プロジェクト: MakFrogz/FinanceBot
def process_group_password(message):
    group.set_temp(message.from_user.id, 'password', message.text)
    group.create_group(message.from_user.id)
    bot.send_message(message.from_user.id, 'Выберите пункт меню:', reply_markup=keyboard.get_main_keyboard())
コード例 #6
0
ファイル: api.py プロジェクト: zachriggle/CTF-Platform
def create_group_hook():
    return group.create_group(session['tid'], request.form.get('name', ''))