Exemple #1
0
def login():
    form = LoginForm()

    params = {'title': 'Аварийный доступ'}

    if form.validate_on_submit():
        return redirect('/success')
    return render_template('login.html', **params, form=form)
Exemple #2
0
def login():
    form = LoginForm()
    if form.validate_on_submit():
        db_sess = db_session.create_session()
        user = db_sess.query(User).filter(User.nickname == form.username.data).first()
        if user and user.check_password(form.password.data):
            login_user(user, remember=True)
            return redirect('/')
        return render_template('login.html', message="Неправильный логин или пароль",
                               form=form)
    return render_template('login.html', form=form)
Exemple #3
0
def login():
    form = LoginForm()
    if form.validate_on_submit():
        db_sess = db_session.create_session()
        user = db_sess.query(User).filter(User.email == form.email.data).first()
        if user and user.check_password(form.password.data):
            login_user(user, remember=form.remember_me.data)
            return redirect("/")
        return render_template('login.html',
                               message="Неправильный логин или пароль",
                               form=form)
    return render_template('login.html', title='Авторизация', form=form)
Exemple #4
0
def login():
    form = LoginForm()
    if form.validate_on_submit():
        # Get the first element in Users which has the same name, or return None
        user = User.query.filter_by(user_name=form.username.data).first()
        if user is not None:
            if security.check_password_hash(user.user_password, form.password.data):
                flash ('You have been logged in')
                session['username'] = user.user_name
                return redirect(url_for('index'))
        flash('Username or password is incorrect, please try again')
    else:
        flash_errors(form)
    return render_template('login.html', title='Login', form=form)
def login():
    if current_user.is_authenticated:
        return redirect(url_for('dashboard'))
    else:
        form = LoginForm()
        if form.validate_on_submit():
            username = form.username.data
            user = User.query.filter_by(username=username).first()
            if user and check_password_hash(user.password, form.password.data):
                
                login_user(user, remember=form.remember.data)
                return redirect(url_for('dashboard'))
            elif not user  :
                flash('Check the user name', "danger")
            else:
                flash('Worng Password',"danger")

        return render_template('login.html', form=form)
Exemple #6
0
def login():
    if current_user.is_authenticated:
        return redirect('/')
    form = LoginForm()
    if form.validate_on_submit():
        db_sess = db_session.create_session()
        user = db_sess.query(User).filter(
            User.name == form.username.data).first()
        logging.info(
            f'User.name: {User.name}; form.username.data: {form.username.data}'
        )
        if user and user.check_password(form.password.data):
            login_user(user, remember=form.remember_me.data)
            return redirect("/")
        return render_template('login.html',
                               message="Неправильный логин или пароль",
                               form=form)
    return render_template('login.html', title='Авторизация', form=form)
Exemple #7
0
def login():
    form = LoginForm()
    if form.validate_on_submit():
        login_request = eval(config_file["Login"]["login_request_structure"])
        login_statuses = eval(config_file["Login"]["login_statuses"])
        user = login_request["user"]
        user["login"] = form.username.data
        user["password_hash"] = hashlib.md5(
            bytes(form.password.data, encoding='utf-8')).hexdigest()
        response = requests.get(URL_API + "login", json=login_request).json()
        status = response["authentication_status"]
        if status == "SUCCESS":
            login_user(convert_user(response), remember=form.remember_me.data)
            return redirect('/')
        return render_template('login.html',
                               form=form,
                               message=login_statuses[status])
    return render_template('login.html', form=form)
Exemple #8
0
def login():
    # авторизация
    form = LoginForm()
    if form.validate_on_submit():
        db_sess = db_session.create_session()
        # Проверка почты
        user = db_sess.query(User).filter(
            User.email == form.email.data).first()
        # и пароля
        if user and user.check_password(form.password.data):
            login_user(user, remember=form.remember_me.data)
            return redirect("/")
        # в случае неверности одного из пунктов, уведомляем об этом
        return render_template('login.html',
                               message="Неправильный логин или пароль",
                               loginform=form,
                               title='Авторизация')
    return render_template('login.html', loginform=form, title='Авторизация')
Exemple #9
0
def login():
    form = LoginForm()
    if form.validate_on_submit():
        db_sess = db_session.create_session()
        user = db_sess.query(User).filter(
            User.login == form.login.data).first()
        if user and form.password.data:
            if user.check_password(form.password.data):
                login_user(user, remember=form.remember_me.data)
                return redirect("/")
        return render_template('login.html',
                               message="Неправильный логин или пароль",
                               form=form,
                               styles=url_for('static',
                                              filename='styles/styles.css'),
                               _logo=url_for('static',
                                             filename=f'images/hat_logo.PNG'))
    return render_template('login.html',
                           title='Авторизация',
                           form=form,
                           _logo=url_for('static',
                                         filename=f'images/hat_logo.PNG'),
                           styles=url_for('static',
                                          filename='styles/styles.css'))