예제 #1
0
def login():
    """
    Handles project account authentication
    """
    if g.project is not None:
        return redirect(url_for('home',
                                project_name=g.project['project_name']))

    form = LoginForm(request.form)
    if form.validate_on_submit():
        # On submit, grab name & password
        project_name = form.project_name.data
        password = form.password.data

        # Try login
        db = DB()
        resp = db.auth(project_name, password)
        if resp['status']:
            session['project_id'] = resp['project_id']

            project_detail = db.get_project_detail(session['project_id'])
            project_name = project_detail['project_name']

            return redirect(url_for('home', project_name=project_name))
        else:
            flash(resp['message'])
    return render_template('login.html', form=form)
예제 #2
0
def admin_login():
    """
    Login for an admin account
    """
    if g.admin is not None:
        return redirect(url_for('admin_home', admin_id=g.admin['project_id']))

    form = LoginForm(request.form)
    if form.validate_on_submit():
        # On submit, grab name & password
        project_name = form.project_name.data
        password = form.password.data

        # Try login
        db = DB()
        resp = db.auth(project_name, password)
        if resp['status'] and resp['admin']:
            session['admin_project_id'] = resp['project_id']

            admin_detail = db.get_project_detail(session['admin_project_id'])
            admin_id = admin_detail['project_id']

            return redirect(url_for('admin_home', admin_id=admin_id))
        elif not resp['admin']:
            flash('Invalid admin account!')
        else:
            flash(resp['message'])
    return render_template('admin_login.html', form=form)
예제 #3
0
            description = raw_input('Description: ')

            resp = db.create(project_name,
                             password,
                             hashed_password,
                             description=description,
                             email=email)
            print json.dumps(resp, indent=1)

        elif method == 'auth':
            """
            python __main__.py db auth project_name password
            """
            project_name = sys.argv[3]
            password = sys.argv[4]
            resp = db.auth(project_name, password)
            print json.dumps(resp, indent=1)

        elif method == 'get_project_list':
            """
            python __main__.py db get_project_list
            """
            resp = db.get_project_list()
            print json.dumps(resp, indent=1)

        elif method == 'get_collector_ids':
            """
            python __main__.py db get_collector_ids project_id
            """
            project_id = sys.argv[3]
            resp = db.get_collector_ids(project_id)
예제 #4
0
파일: __main__.py 프로젝트: bdosono/stack
                add_more = raw_input('Add Another Email [y/n]: ')
                if add_more is not 'y':
                    cont = False

            description = raw_input('Description: ')

            resp = db.create(project_name, password, hashed_password, description=description, email=email)
            print json.dumps(resp, indent=1)

        elif method == 'auth':
            """
            python __main__.py db auth project_name password
            """
            project_name = sys.argv[3]
            password = sys.argv[4]
            resp = db.auth(project_name, password)
            print json.dumps(resp, indent=1)

        elif method == 'get_project_list':
            """
            python __main__.py db get_project_list
            """
            resp = db.get_project_list()
            print json.dumps(resp, indent=1)

        elif method == 'get_collector_ids':
            """
            python __main__.py db get_collector_ids project_id
            """
            project_id = sys.argv[3]
            resp = db.get_collector_ids(project_id)