コード例 #1
0
def login():
    if request.method == 'POST':
        user = data_manager.get_user_by_name(request.form.get('username'))
        if user is None:
            invalid_username_or_password = '******'
            return render_template(
                '/login.html',
                invalid_username_or_password=invalid_username_or_password)

        if user['password'] and password_manager.verify_password(
                request.form['password'], user['password']) is False:
            invalid_username_or_password = '******'
            return render_template(
                '/login.html',
                invalid_username_or_password=invalid_username_or_password)

        session['username'] = user['username']

        # users = data_manager.list_of_users()
        # if request.form.get('username') != users[0]['username']:
        #     invalid_username_or_password = '******'
        #     return render_template('/login.html', invalid_username_or_password=invalid_username_or_password)
        # hash_pw = data_manager.login(request.form['username'])
        # if hash_pw and password_manager.verify_password(request.form['password'], hash_pw) is False:
        #     invalid_username_or_password = '******'
        #     return render_template('/login.html', invalid_username_or_password=invalid_username_or_password)
        # elif hash_pw and password_manager.verify_password(request.form['password'], hash_pw):
        #     session['username'] = request.form['username']
        return redirect('/')
    return render_template('/login.html')
コード例 #2
0
ファイル: main.py プロジェクト: kbarnabas99/proman-deploy
def login_page():
    if request.method == "POST":
        if verify_password(request.form['password'],
                           get_password_hash_for_username(request.form["username"])):
            session['username'] = request.form['username']
            return redirect(url_for('index'))
        else:
            return redirect(url_for("login_page"))
    return render_template("login.html")
コード例 #3
0
def verify_pw():
    session['plain_text_pw'] = request.form.get('password')
    session['hashed_pw'] = request.form.get('hash')

    try:
        is_match = password_manager.verify_password(
            session.get('plain_text_pw'), session.get('hashed_pw'))
    except ValueError:
        is_match = False

    state = 'verified' if is_match else 'failed'

    return render_template('index.html', state=state)
コード例 #4
0
def login():
    if request.method == "POST":
        username = request.form.get("username")
        password = request.form.get('password')
        check_if_user_exists_in_database = queries.verify_user_if_exists(
            username)
        if check_if_user_exists_in_database:
            if verify_password(
                    password, check_if_user_exists_in_database[0]['password']):
                return redirect('/')
            else:
                print("password or username are not correct!")
        else:
            print("password or username are not correct!")
    return render_template('login.html')
コード例 #5
0
ファイル: main.py プロジェクト: Andrei5Moraru/proman
def login():
    if request.method == 'POST':
        user_name = request.form.get('email')
        password = request.form.get('password')
        return_password_if_user_exists = data_handler.check_user(user_name)
        if return_password_if_user_exists:
            if password_manager.verify_password(
                    password, return_password_if_user_exists[0]['password']):
                session['user_name'] = user_name
                return redirect('/')
            else:
                flash("Username or Password incorect!")
        else:
            flash("Username or Password incorect!")

    return render_template("login.html")
コード例 #6
0
def login():
    if request.method == 'POST':
        user = data_handler.get_user_by_name(request.form.get('username'))
        if user is None:
            invalid_username_or_password = '******'
            return render_template(
                '/login.html',
                invalid_username_or_password=invalid_username_or_password)

        if user['password'] and password_manager.verify_password(
                request.form['password'], user['password']) is False:
            invalid_username_or_password = '******'
            return render_template(
                '/login.html',
                invalid_username_or_password=invalid_username_or_password)

        session['username'] = user['username']
        return redirect('/')
    return render_template('/login.html')