Пример #1
0
def signup():

    if not session.get('logged_in'):

        form = forms.LoginForm(request.form)

        if request.method == 'POST':

            username = request.form['username'].lower()

            password = helpers.hash_password(request.form['password'])

            email = request.form['email']

            if form.validate():

                if not helpers.username_taken(username):

                    helpers.add_user(username, password, email)

                    session['logged_in'] = True

                    session['username'] = username

                    return json.dumps({'status': 'Signup successful'})

                return json.dumps({'status': 'Username taken'})

            return json.dumps({'status': 'User/Pass required'})

        return render_template('login.html', form=form)

    return redirect(url_for('login'))
Пример #2
0
def charge():
    if session.get('logged_in'):
        form = forms.LoginForm(request.form)
        if request.method == 'POST':
            username = session.get("username", None)
            password = session.get("password", None)
            email = session.get("email", None)
            coupon = request.form['coupon'].lower()
            if coupon == 'ctsfree':
                paymentflag = 'Y'
                helpers.add_user(username, password, email, paymentflag)
                return render_template('payss.html')
            return json.dumps({'status': 'Payment not successfull'})
        return render_template('login.html', form=form)
    return redirect(url_for('login'))
Пример #3
0
def signup():
    if not session.get("logged_in"):
        form = forms.LoginForm(request.form)
        if request.method == "POST":
            username = request.form["username"].lower()
            password = helpers.hash_password(request.form["password"])
            email = request.form["email"]
            if form.validate():
                if not helpers.username_taken(username):
                    helpers.add_user(username, password, email)
                    session["logged_in"] = True
                    session["username"] = username
                    return json.dumps({"status": "Signup successful"})
                return json.dumps({"status": "Username taken"})
            return json.dumps({"status": "User/Pass required"})
        return render_template("login.html", form=form)
    return redirect(url_for("login"))
Пример #4
0
def authorized():
    resp = google.authorized_response()
    if resp is None:
        return 'Access denied: reason=%s error=%s' % (
            request.args['error_reason'], request.args['error_description'])
    session['google_token'] = (resp['access_token'], '')
    me = google.get('userinfo')
    data = me.data
    email = data['email']
    session['logged_in'] = True
    session['username'] = email
    if helpers.is_registered(email) == 0:
        password = helpers.hash_password(email)
        helpers.add_user(email, password, email)
    user = helpers.get_user_by_email(email)
    id = user.id
    session['userid'] = id
    return redirect(url_for('showcatalogs'))
Пример #5
0
def register():
    if not session.get('logged_in'):
        form = forms.LoginForm(request.form)
        if request.method == 'POST':
            username = request.form['username'].lower()
            password = helpers.hash_password(request.form['password'])
            if form.validate():
                if request.form['password'] == request.form['cpassword']:
                    if not helpers.username_taken(username):
                        helpers.add_user(username, password)
                        session['logged_in'] = True
                        session['username'] = username
                        return redirect(url_for('homepage'))
                    return render_template('register.html', error="Username Taken")
                return render_template('register.html', error="Passwords do not match")
            return render_template('register.html', error="User/Pass Required")
        return render_template('register.html', form=form)
    return redirect(url_for('homepage'))
Пример #6
0
def signup():
    if session.get('logged_in'):
        return redirect(url_for('home'))
    else:
        form = forms.SignupForm(request.form)

        if request.method == 'POST':
            username = request.form['username'].lower()
            password = helpers.hash_password(request.form['password'])
            email = request.form['email']

            if form.validate():
                if not helpers.username_taken(username):
                    helpers.add_user(username, password, email)
                    session['logged_in'] = True
                    session['username'] = username
                    return redirect(url_for('home'))
                flash('Username taken', 'error')
                return render_template("out_facing/signup.html"), 401
            flash("Missing a required field", 'error')
            return render_template("out_facing/signup.html"), 400
        return render_template("out_facing/signup.html")
Пример #7
0
from scripts import create_table
from scripts import helpers

username = '******'
password = '******'
email = '*****@*****.**'
paymentflag = 'Y'
helpers.add_user(username, password, email, paymentflag)