Compare commits

..

6 Commits

Author SHA1 Message Date
d781b1470c extend README 2025-06-18 15:46:50 -07:00
b81c6c9fa3 update totp.py handle pyotp.random_base32() now outputs 32 char string
that won't fit into existing 16char type in the existing app database
2025-06-18 15:07:47 -07:00
0dde8781ec update app/models.py handle jwt.encode now outputs string instead of bytes 2025-06-18 14:19:47 -07:00
4c5510b291 another attempt to get the correct time 2025-06-13 12:15:30 -07:00
7ba4063a84 add gitignore to protect env stuff 2025-06-01 11:15:00 -07:00
6f693c93dc add flaskenv example for local development 2025-06-01 11:14:09 -07:00
6 changed files with 21 additions and 4 deletions

4
.flaskenv.example Normal file
View File

@@ -0,0 +1,4 @@
# use this when developing locally with `flask run`
FLASK_APP=todo.py
FLASK_RUN_HOST="some_host_name"
FLASK_DEBUG="true"

3
.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
.env
.flaskenv
__pycache__/

View File

@@ -260,3 +260,5 @@
&nbsp;&nbsp;&nbsp;&nbsp;&quot;task_pkey&quot; PRIMARY KEY, btree (id)<br />
</p>
## Upgrading from Deb11 -> 12
* install `python3-email-validator`

View File

@@ -8,7 +8,7 @@ from io import BytesIO
def get_totp_qr(contributor, app_config):
totp_key = pyotp.random_base32() if contributor.totp_key is None else contributor.totp_key
totp_key = pyotp.random_base32()[:16] if contributor.totp_key is None else contributor.totp_key
if contributor.totp_key is None:
conn = psycopg2.connect(
dbname=app_config['DATABASE_NAME'],

View File

@@ -54,7 +54,11 @@ class Contributor(UserMixin, db.Model):
return '<Contributor {}>'.format(self.name)
def get_reset_password_token(self, expires_in=1800):
return jwt.encode({'reset_password': self.id, 'exp': time() + expires_in}, app.config['SECRET_KEY'], algorithm='HS256').decode('utf-8')
token = jwt.encode({'reset_password': self.id, 'exp': time() + expires_in}, app.config['SECRET_KEY'], algorithm='HS256')
if type(token) == str:
return token
else:
return token.decode('utf-8')
@staticmethod
def verify_reset_password_token(token):

View File

@@ -4,6 +4,8 @@ from flask import Blueprint, redirect, url_for, render_template
from flask_login import current_user
from app.models import Category, Task
from markdown import markdown
from time import timezone
from datetime import timedelta
tsks = Blueprint(
"tsks", __name__, template_folder="templates"
@@ -25,7 +27,8 @@ def hidden_tasks(category_id):
for task in tasks:
task.markup = markdown(task.content)
task.href = url_for('taskaction.task_action', taskid=task.id)
task.time = task.timestamp.strftime("%Y-%m-%d %H:%M")
local_time = task.timestamp - timedelta(seconds=timezone)
task.time = local_time.strftime("%Y-%m-%d %H:%M")
nl = (
('new', url_for('newtask.new_task', category_id=category_id)),
@@ -56,7 +59,8 @@ def tasks(category_id):
for task in tasks:
task.markup = markdown(task.content)
task.href = url_for('taskaction.task_action', taskid=task.id)
task.time = task.timestamp.strftime("%Y-%m-%d %H:%M")
local_time = task.timestamp - timedelta(seconds=timezone)
task.time = local_time.strftime("%Y-%m-%d %H:%M")
nl = (
('new', url_for('newtask.new_task', category_id=category_id)),