Fix: Gmail SMTP guidance, registration form field, and conditional admin auto-refresh
This commit is contained in:
@@ -2,15 +2,34 @@ from flask import Blueprint, render_template, request, redirect, url_for, flash
|
||||
from flask_login import login_user, logout_user, login_required, current_user
|
||||
from werkzeug.security import check_password_hash
|
||||
from app.models import User, db
|
||||
from app.forms import LoginForm, RegisterForm, ForgotPasswordForm
|
||||
from app.routes.reset_password import RequestResetForm, ResetPasswordForm
|
||||
from flask_mail import Message
|
||||
from app.routes.mail import mail
|
||||
from app.utils.token import generate_reset_token, verify_reset_token
|
||||
import re
|
||||
from app.forms import LoginForm, RegisterForm, ForgotPasswordForm
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import StringField, PasswordField, BooleanField, SubmitField
|
||||
from wtforms.validators import DataRequired, Email, EqualTo, Length
|
||||
|
||||
auth = Blueprint('auth', __name__)
|
||||
|
||||
class LoginForm(FlaskForm):
|
||||
email = StringField('Email', validators=[DataRequired(), Email()])
|
||||
password = PasswordField('Password', validators=[DataRequired()])
|
||||
remember_me = BooleanField('Remember Me')
|
||||
submit = SubmitField('Sign In')
|
||||
|
||||
class RegisterForm(FlaskForm):
|
||||
nickname = StringField('Nickname', validators=[DataRequired(), Length(min=3, max=32)])
|
||||
email = StringField('Email', validators=[DataRequired(), Email()])
|
||||
password = PasswordField('Password', validators=[DataRequired(), Length(min=8)])
|
||||
password2 = PasswordField('Confirm Password', validators=[DataRequired(), EqualTo('password')])
|
||||
submit = SubmitField('Register')
|
||||
|
||||
class ForgotPasswordForm(FlaskForm):
|
||||
email = StringField('Email', validators=[DataRequired(), Email()])
|
||||
submit = SubmitField('Request Password Reset')
|
||||
|
||||
@auth.route('/login', methods=['GET', 'POST'])
|
||||
def login():
|
||||
"""User login page"""
|
||||
|
||||
@@ -229,10 +229,18 @@
|
||||
document.getElementById('sidebar').classList.toggle('show');
|
||||
});
|
||||
|
||||
// Auto-refresh stats every 30 seconds
|
||||
setTimeout(function() {
|
||||
location.reload();
|
||||
}, 30000);
|
||||
// Conditional auto-refresh logic
|
||||
{% if request.endpoint == 'admin.mail_settings' %}
|
||||
{% if settings and settings.enabled %}
|
||||
setTimeout(function() {
|
||||
location.reload();
|
||||
}, 30000);
|
||||
{% endif %}
|
||||
{% else %}
|
||||
setTimeout(function() {
|
||||
location.reload();
|
||||
}, 30000);
|
||||
{% endif %}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
{% extends 'admin/base.html' %}
|
||||
{% block admin_content %}
|
||||
<h2>Mail Server Settings</h2>
|
||||
<div class="alert alert-info" style="max-width:600px;">
|
||||
<strong>Recommended Gmail SMTP Settings:</strong><br>
|
||||
<ul style="margin-bottom:0;">
|
||||
<li><b>Server:</b> smtp.gmail.com</li>
|
||||
<li><b>Port:</b> 587</li>
|
||||
<li><b>Use TLS:</b> True</li>
|
||||
<li><b>Username:</b> your Gmail address (e.g. yourname@gmail.com)</li>
|
||||
<li><b>Password:</b> your Gmail <b>App Password</b> (not your regular password)</li>
|
||||
<li><b>Default sender:</b> your Gmail address (e.g. yourname@gmail.com)</li>
|
||||
</ul>
|
||||
<small>To use Gmail SMTP, you must create an <a href="https://myaccount.google.com/apppasswords" target="_blank">App Password</a> in your Google Account security settings.</small>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="form-group">
|
||||
<label for="enabled">Enable Email Sending</label>
|
||||
|
||||
Reference in New Issue
Block a user