예제 #1
0
def login():
    if not session.get('logged_in'):
        form = forms.LoginForm(request.form)
        if request.method == 'POST':
            username = request.form['username'].lower()
            password = request.form['password']
            if form.validate():
                #if helpers.credentials_valid(username, password):
                session['logged_in'] = True
                session['username'] = username
                return json.dumps({'status': 'Login successful'})
            #return json.dumps({'status': 'Invalid user/pass'})
            return json.dumps({'status': 'Both fields required'})
        return render_template('login.html', form=form)
    user = helpers.get_user()
    sskey = ""
    if 'keyword' in session:
        sskey = session["keyword"]
    simages = ""
    if 'imagePath' in session:
        if session['imagePath'] != "":
            imagePath = session['imagePath']
            print(imagePath)
            if (sskey == ""):
                return render_template("home.html", user=user)
            commonF = Common()
            simages = commonF.sprkSQLReadDFtoList(imagePath, sskey)

            sskey = "You are searching " + sskey
    return render_template('home.html',
                           user=user,
                           searchkey=sskey,
                           hists=simages)
예제 #2
0
파일: app.py 프로젝트: 0x544852/midterms
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'))
예제 #3
0
def login():
    if session.get("fromPredict"):
        session["fromPredict"] = False
    elif session.get("prediction"):
        session.pop("prediction")
        session.pop("confidence")
        if session.get("imageURL"):
            session.pop("imageURL")
        # if(os.path.exists(session.get('segmentImageURL'))):
        #     os.remove(session.get('segmentImageURL'))
        #     print("File Removed!")

    if not session.get("logged_in"):
        form = forms.LoginForm(request.form)
        if request.method == "POST":
            username = request.form["username"].lower()
            password = request.form["password"]
            if form.validate():
                if helpers.credentials_valid(username, password):
                    session["logged_in"] = True
                    session["username"] = username
                    return json.dumps({"status": "Login successful"})
                return json.dumps({"status": "Invalid user/pass"})
            return json.dumps({"status": "Both fields required"})
        return render_template("login.html", form=form)
    user = helpers.get_user()
    return render_template("home.html", user=user)
예제 #4
0
def login():
    if not session.get('logged_in'):
        form = forms.LoginForm(request.form)
        if request.method == 'POST':
            email = request.form['email']
            password = request.form['password']
            if form.validate():
                #auth = helpers.get_auth()
                try:
                    user = auth.sign_in_with_email_and_password(
                        email, password)
                    session['logged_in'] = True
                    session['idToken'] = user['idToken']
                    return json.dumps({'status': 'Login successful'})
                except:
                    return json.dumps({'status': 'Login unsuccessful'})
                return json.dumps({'status': 'Invalid user/pass'})
            return json.dumps({'status': 'Both fields required'})
        return render_template('login.html', form=form)
    user = auth.get_account_info(session['idToken'])
    e = user['users'][0]['email']
    print(e, file=sys.stderr)
    t = helpers.is_in_database(e)
    if t == "yes":
        return render_template('home.html', user=user)
    else:
        return render_template("pay.html", pub_key=pub_key)
예제 #5
0
def login():
    if not session.get('logged_in'):
        form = forms.LoginForm(request.form)
        if request.method == 'POST':
            username = request.form['username'].lower()
            password = request.form['password']
            if form.validate():
                if helpers.credentials_valid(username, password):
                    session['logged_in'] = True
                    session['username'] = username
                    return json.dumps({'status': 'Login successful'})
                return json.dumps({'status': 'Invalid user/pass'})
            return json.dumps({'status': 'Both fields required'})
        return render_template('login.html', form=form)
    user = helpers.get_user()
    fxpairselected = fxpairs[0]
    timeframeselected = timeframes[0]

    #CHECK SUBSCRIPTION
    if user.expiry:
        date = user.expiry
    else:
        date = "0001-01-01"
    return render_template('home.html',
                           user=user,
                           fxpairs=fxpairs,
                           fxpairselected=fxpairselected,
                           timeframes=timeframes,
                           timeframeselected=timeframeselected,
                           date=date,
                           key=stripe_keys['publishable_key'])
예제 #6
0
파일: app.py 프로젝트: ansa-aboudou/resumex
def purchase():
    if not session.get('logged_in'):
        form = forms.LoginForm(request.form)
        return render_template('login.html', form=form)
    message = "To have unlimited ability to add new offers please buy for $1.00 only."
    if helpers.get_pay():
        message = "Thank you for purchasing, you can now add new offers. You can also support us by purchassing again ;)"
    return render_template('purchase.html',
                           key=stripe_keys['publishable_key'],
                           message=message)
예제 #7
0
def signup():
    form = forms.LoginForm(request.form)
    if request.method == 'POST':
        query = request.form['username'].lower()
        print(form.validate())
        if query:
            if helpers.get_natural_language_query(query):
                disc_result=helpers.get_natural_language_query(query)
                return json.dumps({'status': disc_result[0]+" score: "+ str(disc_result[1])+ "ID: "+disc_result[2]})
            return json.dumps({'status': 'no result found'})
        return json.dumps({'status': 'query required'})
    return render_template('login.html', form=form)
예제 #8
0
파일: app.py 프로젝트: ansa-aboudou/resumex
def offer():
    if not session.get('logged_in'):
        form = forms.LoginForm(request.form)
        return render_template('login.html', form=form)
    if request.args:
        if not helpers.get_pay():
            return redirect(url_for('purchase'))
        return redirect(url_for('login'))
    message = "This functionnality is disabled, please purchase before using otherwise the offer will not be added."
    if helpers.get_pay():
        message = ""
        return render_template('offer.html', message=message)
    return render_template('offer_disabled.html', message=message)
예제 #9
0
def login():
    if not session.get('logged_in'):
        form = forms.LoginForm(request.form)
        if request.method == 'POST':
            username = request.form['username'].lower()
            password = request.form['password']
            if username != "" and password != "":
                if helpers.credentials_valid(username, password):
                    session['logged_in'] = True
                    session['username'] = username
                    return redirect(url_for('homepage'))
                return render_template('login.html', error="Invalid username or password.")
            return render_template('login.html', error="Fill in both fields.")
        return render_template('login.html', form=form)
    return redirect(url_for('homepage'))
예제 #10
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'))
예제 #11
0
def login():
    if not session.get('logged_in'):
        form = forms.LoginForm(request.form)
        if request.method == 'POST':
            username = request.form['username'].lower()
            password = request.form['password']
            if form.validate():
                if helpers.credentials_valid(username, password):
                    session['logged_in'] = True
                    session['username'] = username
                    return json.dumps({'status': 'Login successful'})
                return json.dumps({'status': 'Invalid user/pass'})
            return json.dumps({'status': 'Both fields required'})
        return render_template('login.html', form=form)
    user = helpers.get_user()
    return render_template('home.html', user=user)
예제 #12
0
파일: app.py 프로젝트: 0x544852/midterms
def login():    

    if not session.get('logged_in'):

        # user not logged in

        form = forms.LoginForm(request.form)

        if request.method == 'POST':

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

            password = request.form['password']

            if form.validate():

                if helpers.credentials_valid(username, password):

                    session['logged_in'] = True

                    session['username'] = username

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

                return json.dumps({'status': 'Invalid user/pass'})

            return json.dumps({'status': 'Both fields required'})

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

    # user logged in    

    user = helpers.get_user()

    if user.payed == 0: 

    # user must pay    

        return render_template('payment.html', pub_key=pub_key)

    else:

    # user paid already   

        #return render_template('product.html', user=user)

        return render_template('home.html', user=user)
예제 #13
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"))
예제 #14
0
def login():
    if not session.get('logged_in'):
        form = forms.LoginForm(request.form)
        if request.method == 'POST':
            username = request.form['username'].lower()
            password = request.form['password']
            if form.validate():
                if helpers.credentials_valid(username, password):
                    session['logged_in'] = True
                    session['username'] = username
                    return json.dumps({'status': 'Login successful'})
                return json.dumps({'status': 'Invalid user/pass'})
            return json.dumps({'status': 'Both fields required'})
        return render_template('login.html', form=form)

    image_names = os.listdir('static/PeopleNotWearingMask')
    user = helpers.get_user()
    return render_template('home.html', user=user, image_names=image_names, curr = customers.customer.capacity)
예제 #15
0
def signup():
    if not session.get('logged_in'):
        form = forms.LoginForm(request.form)
        if request.method == 'POST':
            password = request.form['password']
            email = request.form['email']
            try:
                #auth = helpers.get_auth()
                user = auth.create_user_with_email_and_password(
                    email, password)
                print(user['idToken'], file=sys.stderr)
                session['logged_in'] = True
                session['idToken'] = user['idToken']
                return json.dumps({'status': 'Signup successful'})
            except:
                return json.dumps({'status': 'Login unsuccessful'})
        return render_template('login.html', form=form)
    return redirect(url_for('login'))
예제 #16
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'))
예제 #17
0
def login():
    '''
    Login check
    '''
    if not session.get('logged_in'):
        form = forms.LoginForm(request.form)
        if request.method == 'POST':
            username = request.form['username'].lower()
            password = request.form['password']
            if form.validate():
                if helpers.credentials_valid(username, password):
                    session['logged_in'] = True
                    session['username'] = username
                    return json.dumps({'status': 'Login successful'})
                return json.dumps({'status': 'Invalid user/pass'})
            return json.dumps({'status': 'Both fields required'})
        return render_template('login.html', form=form)
    user = helpers.get_user()
    '''
    Return memems from HDFS

    Common.py is our core libray written by ourselves to use SparkSQL or do inner-text dection 
    Common.py can be seen in .../Flaskex/
    '''

    sskey = ""
    if 'keyword' in session:
        sskey = session["keyword"]
    simages = ""
    if 'imagePath' in session:
        if session['imagePath'] != "":
            imagePath = session['imagePath']
            print(imagePath)
            if (sskey == ""):
                return render_template("home.html", user=user)
            commonF = Common()
            # Common is written by ourselves to run SparkSQL
            simages = commonF.sprkSQLReadDFtoList(imagePath, sskey)
            # sprkSQLReadDFtoList is to get images from hdfs using SparkSQL
            sskey = "You are searching " + sskey
    return render_template('home.html',
                           user=user,
                           searchkey=sskey,
                           hists=simages)
def login():
    if not session.get('logged_in'):
        if request.method == 'POST':
            username = request.form['username'].lower()
            password = request.form['password']
            if forms.LoginForm(request.form).validate():

                if helpers.credentials_valid(username, password):
                    session['logged_in'] = True
                    session['username'] = username
                    session['email'] = email
                    return jsonify({'status': 'Login successful'})
                else:
                    return jsonify({'status': 'Invalid username/password'})

            else:
                return jsonify({'status': 'Both fields required'})
    else:
        return render_template('home.html')
예제 #19
0
def login():
    form = forms.LoginForm(request.form)

    if request.method == 'POST':
        username = request.form['username'].lower()
        password = request.form['password']
        if form.validate():
            if helpers.credentials_valid(username, password):
                session['logged_in'] = True
                session['username'] = username
                user = helpers.get_user()
                return render_template('home.html', user=user), 200

            else:
                flash('Wrong Username or Password', 'error')
                return render_template("out_facing/login.html"), 401

        else:
            flash('Both fields required', 'error')
            return render_template("out_facing/login.html"), 400

    return render_template("out_facing/login.html")
예제 #20
0
def login():
    if not session.get('logged_in'):
        form = forms.LoginForm(request.form)
        if request.method == 'POST':
            username = request.form['username'].lower()
            password = request.form['password']
            if form.validate():
                if helpers.credentials_valid(username, password):
                    session['logged_in'] = True
                    session['username'] = username
                    return json.dumps({'status': 'Login successful'})
                return json.dumps({'status': 'Invalid user/pass'})
            return json.dumps({'status': 'Both fields required'})
        return render_template('login.html', form=form)
    user = helpers.get_user()
    user.active = user.payment == helpers.payment_token()
    user.key = stripe_keys['publishable_key']
    if user.active:
        disabled = ''
    else:
        disabled = 'disabled'

    return render_template('home.html', user=user, disabled=disabled)