Пример #1
0
def sign():
    if request.method == 'POST':
        email = request.form['inputEmail']
        password = request.form['inputPassword']
        user = mongo.db.users.find_one({'email': email})
        if user:
            if User.validate_login(user['password'], password):
                user_obj = User(email)
                login_user(user_obj)
                return redirect(url_for('user.profile'))
            else:
                print('Incorrect Credentials')
        else:
            return redirect(url_for('home.register'))
    return render_template('home/sign.html')
Пример #2
0
def sign():
    if request.method == 'POST':
        email = request.form['inputEmail']
        user_name = request.form['inputUserName']
        password = request.form['inputPassword']
        corona_table = parser()

        user = mongo.db.users.find_one({'email': email})
        if user:
            if User.validate_login(user['password'], password):
                image_location = mongo.db.users.find_one(
                    {'email': email})['image'].split('/')[-1]
                session['user-email'] = email
                session['user-name'] = user_name
                session['table-data'] = corona_table
                session['user-image'] = image_location
                user_obj = User(email)
                login_user(user_obj)
                return redirect(url_for('user.profile'))
            else:
                print('Incorrect Credentials')
        else:
            return redirect(url_for('home.register'))
    return render_template('home/sign.html')