Ejemplo n.º 1
0
def login():
    if request.method == 'GET':
        return render_template('login.html')
    if request.method == 'POST':
        if 'login-username' in request.form:
            user = users.valid_credentials(db.session,
                                           request.form['login-username'],
                                           request.form['login-password'])
            if user is not None:
                login_user(user, remember=True)
                return redirect(url_for('thread_list_view'))
            else:
                flash(gettext(u'Login failed'))
                return redirect(url_for('login'))
        elif 'apply-username' in request.form:
            user = users.create_user(db.session,
                                     request.form['apply-username'],
                                     request.form['apply-password'],
                                     request.form['apply-email'])
            if user is None:
                flash(u'Username "{0}" is already taken.'.format(
                    request.form['apply-username']))
                return redirect(url_for('login'))
            applicants.create_applicant(db.session, user,
                                        request.form['apply-reason'])
            db.session.commit()
            flash(u'Your application has been sent.')
            return redirect(url_for('login'))
Ejemplo n.º 2
0
def login():
    if request.method == 'GET':
        return render_template('login.html')
    if request.method == 'POST':
        if 'login-username' in request.form:
            user = users.valid_credentials(db.session, request.form['login-username'], request.form['login-password'])
            if user is not None:
                login_user(user, remember=True)
                return redirect(url_for('thread_list_view'))
            else:
                flash(gettext(u'Login failed'))
                return redirect(url_for('login'))
        elif 'apply-username' in request.form:
            user = users.create_user(db.session, request.form['apply-username'], request.form['apply-password'], request.form['apply-email'])
            if user is None:
                flash(u'Username "{0}" is already taken.'.format(request.form['apply-username']))
                return redirect(url_for('login'))
            applicants.create_applicant(db.session, user, request.form['apply-reason'])
            db.session.commit()
            flash(u'Your application has been sent.')
            return redirect(url_for('login'))
Ejemplo n.º 3
0
    db.drop_all()

    db.create_all()

    print 'Tables created...'

    if args.opt == 'production':
        # Do a real install...
        # Don't know what that will look like yet?
        print 'Create a user'
        print '-------------'
        name = raw_input('Name: ')
        try:
            password = getpass.getpass()
        except getpass.GetPassWarning:
            print '***WARNING: Password may be visible in the terminal!'
            password = getpass.getpass()
        email = raw_input('Email: ')

        user = users.create_user(db.session, name, password, email)
        applicant = applicants.create_applicant(db.session, user, 'ingroup creator')
        db.session.flush()
        applicants.accept_applicant(db.session, applicant.id, user)
        db.session.commit()
        print 'User successfully created.'
    else:
        # Don't add any defaults to the database.
        print 'Note: Tables are empty without data.'

print 'Done.'