Answer the question
In order to leave comments, you need to log in
Why doesn't it count authorization?
Authorization
@app.route('/auth' , methods=['GET', 'POST'])
def special():
if current_user.is_authenticated:
return redirect(url_for('special_control'))
form = LoginForm()
if form.validate_on_submit():
user = SuperUser.query.filter_by(login=form.username.data).first()
if user is None or not user.check_password(form.password.data):
flash('Invalid username or password')
return redirect(url_for('special'))
login_user(user, remember=form.remember_me.data)
return redirect(url_for('special_control'))
return render_template('/products/login.html', form=form, title='Авторизация')
@app.route('/control')
@login_required
def special_control():
return render_template('/products/control_panel.html', title='Панель управления', )
class LoginForm(FlaskForm):
username = StringField('Username', validators=[DataRequired()])
password = PasswordField('Password', validators=[DataRequired()])
remember_me = BooleanField('Remember Me')
submit = SubmitField('Sign In')
<form action="" method="post" novalidate>
{{ form.hidden_tag() }}
<p>
<p style="margin-left: 35%;">{{ form.username.label }}</p><br>
<p>{{ form.username(size=32) }}</p><br>
{% for error in form.username.errors %}
<span style="color: #ff0000;">[{{ error }}]</span>
{% endfor %}
</p>
<p>
<p style="margin-left: 36%;">{{ form.password.label }}</p><br>
<p>{{ form.password(size=32) }}</p><br>
{% for error in form.password.errors %}
<span style="color: #ff0000;">[{{ error }}]</span>
{% endfor %}
</p>
<p style="margin-left: 27%;">{{ form.remember_me() }} {{ form.remember_me.label }}</p>
<p style="margin-left: 37%;">{{ form.submit() }}</p>
</form>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question