Added remember login for 30 days
This commit is contained in:
@@ -32,6 +32,8 @@ app.config['SECRET_KEY'] = os.environ.get('SECRET_KEY')
|
|||||||
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('DATABASE_URL')
|
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('DATABASE_URL')
|
||||||
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = os.environ.get('SQLALCHEMY_TRACK_MODIFICATIONS')
|
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = os.environ.get('SQLALCHEMY_TRACK_MODIFICATIONS')
|
||||||
app.config['TEMPLATES_AUTO_RELOAD'] = os.environ.get('TEMPLATES_AUTO_RELOAD')
|
app.config['TEMPLATES_AUTO_RELOAD'] = os.environ.get('TEMPLATES_AUTO_RELOAD')
|
||||||
|
# Session configuration for "Remember Me" functionality
|
||||||
|
app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(days=30)
|
||||||
|
|
||||||
# Initialize database
|
# Initialize database
|
||||||
db = SQLAlchemy(app)
|
db = SQLAlchemy(app)
|
||||||
@@ -1529,6 +1531,15 @@ def login():
|
|||||||
).first()
|
).first()
|
||||||
|
|
||||||
if user and user.check_password(password):
|
if user and user.check_password(password):
|
||||||
|
# Check if "Remember Me" is checked
|
||||||
|
remember_me = request.form.get('remember_me') == 'on'
|
||||||
|
|
||||||
|
# Set session as permanent if "Remember Me" is checked
|
||||||
|
if remember_me:
|
||||||
|
session.permanent = True
|
||||||
|
else:
|
||||||
|
session.permanent = False
|
||||||
|
|
||||||
# Successful login
|
# Successful login
|
||||||
session['user_id'] = user.id
|
session['user_id'] = user.id
|
||||||
session['username'] = user.username
|
session['username'] = user.username
|
||||||
|
|||||||
@@ -34,6 +34,19 @@
|
|||||||
<input type="password" id="password" name="password" required />
|
<input type="password" id="password" name="password" required />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Remember Me Checkbox -->
|
||||||
|
<div class="form-group" style="margin-top: 1rem; margin-bottom: 1.5rem;">
|
||||||
|
<label style="display: flex; align-items: center; cursor: pointer; font-weight: normal;">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
id="remember_me"
|
||||||
|
name="remember_me"
|
||||||
|
style="margin-right: 0.5rem; width: auto; cursor: pointer;"
|
||||||
|
/>
|
||||||
|
<span>Remember me for 30 days</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Turnstile Integration -->
|
<!-- Turnstile Integration -->
|
||||||
{% if turnstile_enabled %}
|
{% if turnstile_enabled %}
|
||||||
<div class="form-group turnstile-container">
|
<div class="form-group turnstile-container">
|
||||||
|
|||||||
Reference in New Issue
Block a user