update copyright and clean up comments

This commit is contained in:
itwrx 2025-05-17 09:02:52 -05:00
parent eba14223f1
commit 04b3317f42
16 changed files with 64 additions and 148 deletions

View File

@ -1,6 +1,6 @@
#[Copyright 2025 ITwrx. #[Copyright 2025 ITwrx.
This file is part of Simple Site Manager. This file is part of Forget-Me-Not.
Simple Site Manager is released under the GNU Affero General Public License 3.0. Forget-Me-Not is released under the GNU Affero General Public License 3.0.
See COPYING or <https://www.gnu.org/licenses/> for details.]# See COPYING or <https://www.gnu.org/licenses/> for details.]#
import guildenstern/[epolldispatcher, httpserver], sqliteral import guildenstern/[epolldispatcher, httpserver], sqliteral
@ -54,7 +54,6 @@ proc handlePost() =
if uri == "/send-reminders": if uri == "/send-reminders":
sendRemindersPostHandler() sendRemindersPostHandler()
let fr = getFormResult() let fr = getFormResult()
#let csrfTokenInput = formInput("csrf_token")
if uri == "/login": if uri == "/login":
if isValidVisitorCsrfToken(formInput("csrf_token")): if isValidVisitorCsrfToken(formInput("csrf_token")):
loginPostHandler() loginPostHandler()

View File

@ -1,16 +1,14 @@
#[Copyright 2025 ITwrx. #[Copyright 2025 ITwrx.
This file is part of Simple Site Manager. This file is part of Forget-Me-Not.
Simple Site Manager is released under the GNU Affero General Public License 3.0. Forget-Me-Not is released under the GNU Affero General Public License 3.0.
See COPYING or <https://www.gnu.org/licenses/> for details.]# See COPYING or <https://www.gnu.org/licenses/> for details.]#
#TODO: remove code not being used in this application. Some of this is only needed in Simple Site Manager.
import std/[cgi, strtabs, cookies, sysrand, base64] import std/[cgi, strtabs, cookies, sysrand, base64]
import guildenstern/[httpserver], sqliteral import guildenstern/[httpserver], sqliteral
import "../models/session", "db", "global" import "../models/session", "db", "global"
#[type
Session* = object
sessionId*, csrfToken*: string
id*, userId*: int]#
type type
User* = object User* = object
email*, password*: string email*, password*: string
@ -54,9 +52,6 @@ proc setVisitorCsrfToken*(): string =
#create csrf token. #create csrf token.
var csrfToken = $urandom(32) var csrfToken = $urandom(32)
csrfToken = base64.encode(csrfToken) csrfToken = base64.encode(csrfToken)
#delete old VisitorSessions, as they are just the one time use CSRF Tokens.
#may need to be redesigned for better multiuser robustness if it's deleting other users' unused tokens.
#deleteVisitorSessions()
#create session in db. #create session in db.
var visitorSession: Session var visitorSession: Session
visitorSession.csrfToken = csrfToken visitorSession.csrfToken = csrfToken
@ -78,12 +73,6 @@ proc newCsrfToken*(): string =
csrfToken = base64.encode(csrfToken) csrfToken = base64.encode(csrfToken)
return csrfToken return csrfToken
#[proc fCsrfToken*(): string =
{.gcsafe.}:
let sessionId = getSessionIdFromCookies()
let userSession = getUserSessionBySessionId(sessionId)
result = userSession.csrfToken]#
proc isValidVisitorCsrfToken*(csrfToken: string): bool = proc isValidVisitorCsrfToken*(csrfToken: string): bool =
#our previoulsy self-generated, valid csrfToken from the DB. #our previoulsy self-generated, valid csrfToken from the DB.
let visitorSessionCsrfToken = getSessionByCsrfToken(csrfToken).csrfToken let visitorSessionCsrfToken = getSessionByCsrfToken(csrfToken).csrfToken

View File

@ -1,3 +1,8 @@
#[Copyright 2025 ITwrx.
This file is part of Forget-Me-Not.
Forget-Me-Not is released under the GNU Affero General Public License 3.0.
See COPYING or <https://www.gnu.org/licenses/> for details.]#
import std/[times, strutils] import std/[times, strutils]
proc weekdayFromString(dayStr: string): Weekday = proc weekdayFromString(dayStr: string): Weekday =
@ -41,7 +46,6 @@ proc nextWeekday*(targetWeekdayString: string): DateTime =
proc nthWeekdayInMonth*(year: int, month: Month, weekdayString: string, nth: range[1..3]): DateTime = proc nthWeekdayInMonth*(year: int, month: Month, weekdayString: string, nth: range[1..3]): DateTime =
# Start from the first day of the month # Start from the first day of the month
#var currentDate = dateTime(year, month, 1, 0, 0, 0, 0)
var currentDate = dateTime(year, month, 1) var currentDate = dateTime(year, month, 1)
let weekday = weekdayFromString(weekdayString) let weekday = weekdayFromString(weekdayString)
# Find the first occurrence of the specified weekday # Find the first occurrence of the specified weekday
@ -53,7 +57,6 @@ proc nthWeekdayInMonth*(year: int, month: Month, weekdayString: string, nth: ran
proc lastWeekdayInMonth(year: int, month: Month, weekdayString: string): DateTime = proc lastWeekdayInMonth(year: int, month: Month, weekdayString: string): DateTime =
# Create a DateTime for the last day of the given month # Create a DateTime for the last day of the given month
#var lastDay = dateTime(year, month, getDaysInMonth(month, year), 0, 0, 0, 0)
var lastDay = dateTime(year, month, getDaysInMonth(month, year)) var lastDay = dateTime(year, month, getDaysInMonth(month, year))
let weekday = weekdayFromString(weekdayString) let weekday = weekdayFromString(weekdayString)
# Work backwards until we find the last occurrence of the specified weekday # Work backwards until we find the last occurrence of the specified weekday
@ -100,53 +103,19 @@ proc nextYearlyOnWeekdayOfWeekOfMonth*(weekdayString, ocurrence, monthString: st
nextSendDate = lastWeekdayInMonth(year(startingDate), month(startingDate), weekdayString) nextSendDate = lastWeekdayInMonth(year(startingDate), month(startingDate), weekdayString)
return nextSendDate return nextSendDate
#[proc nextYearDate*(monthString: string, day: int): DateTime = #[ Returns the next occurrence of the specified month and day, which could be:
## Aalways returns a date in the next year, - Later this year if the target date hasn't occurred yet
## regardless of whether the target date has passed in the current year - Next year if the target date has already passed this year]#
#var nextSendDate = dateTime(year(now()) + 1, monthFromString(monthString), day, 0, 0, 0, 0)
#var nextSendDate = dateTime(year(now()) + 1, monthFromString(monthString), day)
#let nextSendDateString =
#echo nextSendDate
#return parse($nextSendDate, "yyyy-MM-dd")
var
let nextYear = year(now()) + 1
let dt = dateTime(nextYear, monthFromString(monthString), day, 00, 00, 00, 00)
#echo dt
let nextSendDateString = format(dt, "yyyy-MM-dd")
#echo nextSendDateString
#let nextSendDateString = $nextYear & "-" & formattedMonthString & "-" & $day
let nextSendDate = parse(nextSendDateString, "yyyy-MM-dd")
#echo nextSendDateString
return nextSendDate]#
proc nextYearlyDate*(monthString: string, targetDay: int): DateTime = proc nextYearlyDate*(monthString: string, targetDay: int): DateTime =
## Calculates a date for the next occurrence of a specific month and day
##
## Parameters:
## - baseDate: The starting date to calculate from
## - targetMonth: The month (Month enum) for the target date
## - targetDay: The day of month for the target date
##
## Returns the next occurrence of the specified month and day, which could be:
## - Later this year if the target date hasn't occurred yet
## - Next year if the target date has already passed this year
let baseDate = now() let baseDate = now()
let targetMonth = monthFromString(monthString) let targetMonth = monthFromString(monthString)
# Get the current year # Get the current year
let currentYear = baseDate.year let currentYear = baseDate.year
# Create a DateTime for the target date in the current year # Create a DateTime for the target date in the current year
var nextSendDate = dateTime(currentYear, targetMonth, targetDay, 00, 00, 00, 00) var nextSendDate = dateTime(currentYear, targetMonth, targetDay, 00, 00, 00, 00)
# If the target date has already passed this year, move to next year # If the target date has already passed this year, move to next year
if nextSendDate <= baseDate: if nextSendDate <= baseDate:
nextSendDate = dateTime(currentYear + 1, targetMonth, targetDay, 00, 00, 00, 00) nextSendDate = dateTime(currentYear + 1, targetMonth, targetDay, 00, 00, 00, 00)
let nextSendDateString = format(nextSendDate, "yyyy-MM-dd") let nextSendDateString = format(nextSendDate, "yyyy-MM-dd")
#echo nextSendDateString
#let nextSendDateString = $nextYear & "-" & formattedMonthString & "-" & $day
nextSendDate = parse(nextSendDateString, "yyyy-MM-dd") nextSendDate = parse(nextSendDateString, "yyyy-MM-dd")
return nextSendDate return nextSendDate

View File

@ -1,6 +1,6 @@
#[Copyright 2024 ITwrx. #[Copyright 2024 ITwrx.
This file is part of Simple Site Manager. This file is part of Forget-Me-Not.
Simple Site Manager is released under the GNU Affero General Public License 3.0. Forget-Me-Not is released under the GNU Affero General Public License 3.0.
See COPYING or <https://www.gnu.org/licenses/> for details.]# See COPYING or <https://www.gnu.org/licenses/> for details.]#
import sqliteral import sqliteral

View File

@ -1,8 +1,10 @@
#[Copyright 2025 ITwrx. #[Copyright 2025 ITwrx.
This file is part of Simple Site Manager. This file is part of Forget-Me-Not.
Simple Site Manager is released under the GNU Affero General Public License 3.0. Forget-Me-Not is released under the GNU Affero General Public License 3.0.
See COPYING or <https://www.gnu.org/licenses/> for details.]# See COPYING or <https://www.gnu.org/licenses/> for details.]#
#TODO: remove anything not being used by Forget-Me-Not.
import std/[cgi, strtabs, strutils, cookies, uri, tables] import std/[cgi, strtabs, strutils, cookies, uri, tables]
import jsony, guildenstern/httpserver, sqliteral import jsony, guildenstern/httpserver, sqliteral
import "auth", "global" import "auth", "global"

View File

@ -1,10 +1,15 @@
#import std/[times, logging] #[Copyright 2025 ITwrx.
This file is part of Forget-Me-Not.
Forget-Me-Not is released under the GNU Affero General Public License 3.0.
See COPYING or <https://www.gnu.org/licenses/> for details.]#
import std/[times, strutils, re, uri, paths, random, strtabs] import std/[times, strutils, re, uri, paths, random, strtabs]
#universal #universal
const APP_PATH* = "/var/www/forget-me-not-gs" const APP_PATH* = "/var/www/forget-me-not-gs"
const ASSETS_PATH* = "/var/www/forget-me-not-gs/app/assets" const ASSETS_PATH* = "/var/www/forget-me-not-gs/app/assets"
const APP_NAME* = "Forget-Me-Not" const APP_NAME* = "Forget-Me-Not"
#set to 'dev' or 'prod'
const APP_MODE* = "dev" const APP_MODE* = "dev"
#dev #dev
const APP_URL* = "http://fmn-gs" const APP_URL* = "http://fmn-gs"
@ -17,6 +22,8 @@ const ASSETS_URL* = "http://assets.fmn-gs"
var frStrTab* = newStringTable() var frStrTab* = newStringTable()
#TODO: implement logging or remove logging code.
#Guildensterns logger is conflicting with my, evidently incorrect, usage of the std lib logger so i'll just write some lines to a file for now. #Guildensterns logger is conflicting with my, evidently incorrect, usage of the std lib logger so i'll just write some lines to a file for now.
#var logger* = newFileLogger("errors.log") #var logger* = newFileLogger("errors.log")
@ -29,7 +36,6 @@ proc writeLogLine*(errorMsg: string) =
defer: logFile.close() defer: logFile.close()
logFile.writeLine(errorMsg) logFile.writeLine(errorMsg)
#template location*(slug: string, csrfToken: string, fr: FormResult): untyped =
template location*(slug: string): untyped = template location*(slug: string): untyped =
"location: " & APP_URL & slug "location: " & APP_URL & slug

View File

@ -1,3 +1,8 @@
#[Copyright 2025 ITwrx.
This file is part of Forget-Me-Not.
Forget-Me-Not is released under the GNU Affero General Public License 3.0.
See COPYING or <https://www.gnu.org/licenses/> for details.]#
import std/[times, osproc], smtp import std/[times, osproc], smtp
import ../models/reminder, ../models/user, datetime import ../models/reminder, ../models/user, datetime

View File

@ -1,6 +1,6 @@
#[Copyright 2024 ITwrx. #[Copyright 2025 ITwrx.
This file is part of ITwrxorg-SiteUpdata. This file is part of Forget-Me-Not.
ITwrxorg-SiteUpdata is released under the GNU Affero General Public License 3.0. Forget-Me-Not is released under the GNU Affero General Public License 3.0.
See COPYING or <https://www.gnu.org/licenses/> for details.]# See COPYING or <https://www.gnu.org/licenses/> for details.]#
import std/[strutils, re, typetraits, times, tables] import std/[strutils, re, typetraits, times, tables]

View File

@ -1,10 +1,11 @@
#[Copyright 2024 ITwrx. #[Copyright 2025 ITwrx.
This file is part of Simple Site Manager. This file is part of Forget-Me-Not.
Simple Site Manager is released under the GNU Affero General Public License 3.0. Forget-Me-Not is released under the GNU Affero General Public License 3.0.
See COPYING or <https://www.gnu.org/licenses/> for details.]# See COPYING or <https://www.gnu.org/licenses/> for details.]#
#TODO: Use a human checker in login form or remove from project.
import std/random import std/random
#import sqliteral, "../helpers/db"
type type
HumanChecker* = object HumanChecker* = object
@ -35,32 +36,3 @@ proc getHCById*(id: int): HumanChecker =
for hc in humanCheckers: for hc in humanCheckers:
if hc.id == id: if hc.id == id:
return hc return hc
#for some reason we are creating the humanCheckers here and then checking them from the DB, instead of one data location or the other, like we probably should have.
#the below was probably supposed to be a test, but then it just stayed like that.
#[proc getHumanChecker*(): HumanChecker =
{.gcsafe.}:
randomize()
var humanCheckers{.threadvar.}: seq[HumanChecker]
humanCheckers.add(HumanChecker(id: 1, question: "26 + four, minus 10", answer: 20))
humanCheckers.add(HumanChecker(id: 2, question: "10 minus 2, + 14", answer: 22))
humanCheckers.add(HumanChecker(id: 3, question: "15 + five, minus 3", answer: 17))
humanCheckers.add(HumanChecker(id: 4, question: "9 + nine, minus 6", answer: 12))
humanCheckers.add(HumanChecker(id: 5, question: "13 - three, plus 5", answer: 15))
humanCheckers.add(HumanChecker(id: 6, question: "7 + six, plus one", answer: 14))
humanCheckers.add(HumanChecker(id: 7, question: "22 + 8, - 2", answer: 28))
humanCheckers.add(HumanChecker(id: 8, question: "4 - four, + ten", answer: 10))
humanCheckers.add(HumanChecker(id: 9, question: "16 + four, minus three", answer: 17))
humanCheckers.add(HumanChecker(id: 10, question: "twelve minus four, plus 8", answer: 16))
return sample(humancheckers)
proc getHCById*(id: int): HumanChecker =
{.gcsafe.}:
var hc {.threadvar.}: HumanChecker
#prepareDb2SQL()
for row in db2.rows(SelectHumanCheckerById, id):
hc.id = row.getInt(0)
hc.question = row.getString(1)
hc.answer = row.getInt(2)
return hc]#

View File

@ -1,9 +1,8 @@
#[Copyright 2024 ITwrx. #[Copyright 2025 ITwrx.
This file is part of Simple Site Manager. This file is part of Forget-Me-Not.
Simple Site Manager is released under the GNU Affero General Public License 3.0. Forget-Me-Not is released under the GNU Affero General Public License 3.0.
See COPYING or <https://www.gnu.org/licenses/> for details.]# See COPYING or <https://www.gnu.org/licenses/> for details.]#
#import sqliteral, "../helpers/db", "../helpers/global.nim", sequtils, algorithm, times
import sqliteral, "../helpers/db", algorithm, times import sqliteral, "../helpers/db", algorithm, times
type type
@ -13,9 +12,6 @@ type
var allReminders: seq[Reminder] var allReminders: seq[Reminder]
#proc myCmp(x, y: Reminder): int =
# cmp(x.sendDate, y.sendDate)
proc getReminderSendDatetime*(reminder: Reminder): DateTime = proc getReminderSendDatetime*(reminder: Reminder): DateTime =
let sendDateDTString = $reminder.sendDate & " " & $reminder.sendTimeHr & ":" & $reminder.sendTimeMin & ":" & $reminder.sendTimeAmPm let sendDateDTString = $reminder.sendDate & " " & $reminder.sendTimeHr & ":" & $reminder.sendTimeMin & ":" & $reminder.sendTimeAmPm
#single digits for minutes, as db send_time_min is integer and won't use "00", which results in runtime parse error. #single digits for minutes, as db send_time_min is integer and won't use "00", which results in runtime parse error.

View File

@ -1,6 +1,6 @@
#[Copyright 2024 ITwrx. #[Copyright 2025 ITwrx.
This file is part of Simple Site Manager. This file is part of Forget-Me-Not.
Simple Site Manager is released under the GNU Affero General Public License 3.0. Forget-Me-Not is released under the GNU Affero General Public License 3.0.
See COPYING or <https://www.gnu.org/licenses/> for details.]# See COPYING or <https://www.gnu.org/licenses/> for details.]#
import sqliteral, "../helpers/db" import sqliteral, "../helpers/db"

View File

@ -1,6 +1,6 @@
#[Copyright 2025 ITwrx. #[Copyright 2025 ITwrx.
This file is part of Simple Site Manager. This file is part of Forget-Me-Not.
Simple Site Manager is released under the GNU Affero General Public License 3.0. Forget-Me-Not is released under the GNU Affero General Public License 3.0.
See COPYING or <https://www.gnu.org/licenses/> for details.]# See COPYING or <https://www.gnu.org/licenses/> for details.]#
import sqliteral, "../helpers/db" import sqliteral, "../helpers/db"

View File

@ -1,6 +1,6 @@
#[Copyright 2025 ITwrx. #[Copyright 2025 ITwrx.
This file is part of Simple Site Manager. This file is part of Forget-Me-Not.
Simple Site Manager is released under the GNU Affero General Public License 3.0. Forget-Me-Not is released under the GNU Affero General Public License 3.0.
See COPYING or <https://www.gnu.org/licenses/> for details.]# See COPYING or <https://www.gnu.org/licenses/> for details.]#
import guildenstern/httpserver import guildenstern/httpserver
@ -23,7 +23,6 @@ proc loginPostHandler*() =
#discard assignErrorFR(formErrors, formOldInputs, csrfTokenInput) #discard assignErrorFR(formErrors, formOldInputs, csrfTokenInput)
discard assignErrorFR(formErrors, formOldInputs) discard assignErrorFR(formErrors, formOldInputs)
let frJson = formResult.toJson() let frJson = formResult.toJson()
#let cookieHeader = "Set-Cookie: form_result=" & frJson & ";" & "HttpOnly;" & "path=/;"
if APP_MODE == "dev": if APP_MODE == "dev":
cookieHeader1 = "Set-Cookie: form_result=" & frJson & ";" & "HttpOnly;" & "path=/;" & "SameSite=Lax;" cookieHeader1 = "Set-Cookie: form_result=" & frJson & ";" & "HttpOnly;" & "path=/;" & "SameSite=Lax;"
else: else:
@ -46,14 +45,6 @@ proc loginPostHandler*() =
discard assignLoginSuccessFR() discard assignLoginSuccessFR()
let frJson = formResult.toJson() let frJson = formResult.toJson()
#redirect, and set session cookie. #redirect, and set session cookie.
#will probably need to detect requested url for redirect (with static fallback) instead of just static location.
#Set-Cookie: <cookie-name>=<cookie-value>; Domain=<domain-value>; Secure; HttpOnly
#dev
#let cookieHeader1 = "Set-Cookie: " & APP_NAME & "_session=" & sessionId & ";" & "HttpOnly;" & "SameSite=Lax;"
#let cookieHeader2 = "Set-Cookie: form_result=" & frJson & ";" & "HttpOnly;" & "path=/;" & "SameSite=Lax;"
#prod
#let cookieHeader1 = "Set-Cookie: " & APP_NAME & "_session=" & sessionId & ";" & "HttpOnly;" & "Secure=true;" & "SameSite=Lax;"
#let cookieHeader2 = "Set-Cookie: form_result=" & frJson & ";" & "HttpOnly;" & "Secure=true;" & "path=/;" & "SameSite=Lax;"
if APP_MODE == "dev": if APP_MODE == "dev":
cookieHeader1 = "Set-Cookie: " & APP_NAME & "_session=" & sessionId & ";" & "HttpOnly;" & "SameSite=Lax;" cookieHeader1 = "Set-Cookie: " & APP_NAME & "_session=" & sessionId & ";" & "HttpOnly;" & "SameSite=Lax;"
cookieHeader2 = "Set-Cookie: form_result=" & frJson & ";" & "HttpOnly;" & "path=/;" & "SameSite=Lax;" cookieHeader2 = "Set-Cookie: form_result=" & frJson & ";" & "HttpOnly;" & "path=/;" & "SameSite=Lax;"
@ -74,8 +65,6 @@ proc loginPostHandler*() =
formResult.errors = toJson(formErrors) formResult.errors = toJson(formErrors)
formResult.oldInputs = getOldInputJson() formResult.oldInputs = getOldInputJson()
let frJson = formResult.toJson() let frJson = formResult.toJson()
#let cookieHeader = "Set-Cookie: form_result=" & frJson & ";" & "HttpOnly;"
#let cookieHeader = "Set-Cookie: form_result=" & frJson & ";" & "HttpOnly;" & "path=/;"
if APP_MODE == "dev": if APP_MODE == "dev":
cookieHeader1 = "Set-Cookie: form_result=" & frJson & ";" & "HttpOnly;" & "path=/;" & "SameSite=Lax;" cookieHeader1 = "Set-Cookie: form_result=" & frJson & ";" & "HttpOnly;" & "path=/;" & "SameSite=Lax;"
else: else:
@ -91,7 +80,6 @@ proc loginPostHandler*() =
formResult.errors = toJson(formErrors) formResult.errors = toJson(formErrors)
formResult.oldInputs = getOldInputJson() formResult.oldInputs = getOldInputJson()
let frJson = formResult.toJson() let frJson = formResult.toJson()
#let cookieHeader = "Set-Cookie: form_result=" & frJson & ";" & "HttpOnly;" & "path=/;"
if APP_MODE == "dev": if APP_MODE == "dev":
cookieHeader1 = "Set-Cookie: form_result=" & frJson & ";" & "HttpOnly;" & "path=/;" & "SameSite=Lax;" cookieHeader1 = "Set-Cookie: form_result=" & frJson & ";" & "HttpOnly;" & "path=/;" & "SameSite=Lax;"
else: else:
@ -100,7 +88,6 @@ proc loginPostHandler*() =
except Exception as e: except Exception as e:
echo e.msg echo e.msg
#reply(Http500)
discard assignGeneralErrorFR(e.msg) discard assignGeneralErrorFR(e.msg)
setFR() setFR()
reply(Http303, [location("/500")]) reply(Http303, [location("/500")])

View File

@ -1,6 +1,6 @@
#[Copyright 2024 ITwrx. #[Copyright 2025 ITwrx.
This file is part of Simple Site Manager. This file is part of Forget-Me-Not.
Simple Site Manager is released under the GNU Affero General Public License 3.0. Forget-Me-Not is released under the GNU Affero General Public License 3.0.
See COPYING or <https://www.gnu.org/licenses/> for details.]# See COPYING or <https://www.gnu.org/licenses/> for details.]#
import guildenstern/httpserver import guildenstern/httpserver
@ -12,7 +12,6 @@ proc reminderCreatePostHandler*() =
try: try:
#attempt validation first. #attempt validation first.
vInput("title", @["required", "string", "max:150"]) vInput("title", @["required", "string", "max:150"])
#vInput("subject", @["string", "max:175"])
vInput("message", @["required", "string", "max:255"]) vInput("message", @["required", "string", "max:255"])
vInput("notify_via", @["required", "string", "max:5"]) vInput("notify_via", @["required", "string", "max:5"])
vInput("repeats", @["integer", "max:1"]) vInput("repeats", @["integer", "max:1"])
@ -33,7 +32,6 @@ proc reminderCreatePostHandler*() =
#create formResult and redirect on validation errors. #create formResult and redirect on validation errors.
if formErrors.len > 0: if formErrors.len > 0:
addFormOldInput("title", formInput("title")) addFormOldInput("title", formInput("title"))
#addFormOldInput("subject", formInput("subject"))
addFormOldInput("message", formInput("message")) addFormOldInput("message", formInput("message"))
addFormOldInput("notify_via", formInput("notify_via")) addFormOldInput("notify_via", formInput("notify_via"))
addFormOldInput("repeats", formInput("repeats")) addFormOldInput("repeats", formInput("repeats"))
@ -58,7 +56,6 @@ proc reminderCreatePostHandler*() =
else: else:
var reminder: Reminder var reminder: Reminder
reminder.title = formInput("title") reminder.title = formInput("title")
#reminder.subject = formInput("subject")
reminder.message = formInput("message") reminder.message = formInput("message")
reminder.notifyVia = formInput("notify_via") reminder.notifyVia = formInput("notify_via")
reminder.repeats = formInputInt("repeats") reminder.repeats = formInputInt("repeats")
@ -83,7 +80,6 @@ proc reminderCreatePostHandler*() =
reply(Http303, [location("/")]) reply(Http303, [location("/")])
except CatchableError as e: except CatchableError as e:
echo e.msg echo e.msg
#reply(Http500)
discard assignGeneralErrorFR(e.msg) discard assignGeneralErrorFR(e.msg)
setFR() setFR()
reply(Http303, [location("/500")]) reply(Http303, [location("/500")])
@ -93,7 +89,6 @@ proc reminderUpdatePostHandler*() =
#var origin = http.headers.getOrDefault("origin") #var origin = http.headers.getOrDefault("origin")
#attempt validation first. #attempt validation first.
vInput("title", @["required", "string", "max:150"]) vInput("title", @["required", "string", "max:150"])
#vInput("subject", @["string", "max:175"])
vInput("message", @["required", "string", "max:255"]) vInput("message", @["required", "string", "max:255"])
vInput("notify_via", @["required", "string", "max:5"]) vInput("notify_via", @["required", "string", "max:5"])
vInput("repeats", @["integer", "max:1"]) vInput("repeats", @["integer", "max:1"])
@ -115,7 +110,6 @@ proc reminderUpdatePostHandler*() =
if formErrors.len > 0: if formErrors.len > 0:
#since validation failed we better keep add the old inputs. #since validation failed we better keep add the old inputs.
addFormOldInput("title", formInput("title")) addFormOldInput("title", formInput("title"))
#addFormOldInput("subject", formInput("subject"))
addFormOldInput("message", formInput("message")) addFormOldInput("message", formInput("message"))
addFormOldInput("notify_via", formInput("notify_via")) addFormOldInput("notify_via", formInput("notify_via"))
addFormOldInput("repeats", formInput("repeats")) addFormOldInput("repeats", formInput("repeats"))
@ -141,7 +135,6 @@ proc reminderUpdatePostHandler*() =
var reminder: Reminder var reminder: Reminder
reminder.id = formInputInt("reminder_id") reminder.id = formInputInt("reminder_id")
reminder.title = formInput("title") reminder.title = formInput("title")
#reminder.subject = formInput("subject")
reminder.message = formInput("message") reminder.message = formInput("message")
reminder.notifyVia = formInput("notify_via") reminder.notifyVia = formInput("notify_via")
reminder.repeats = formInputInt("repeats") reminder.repeats = formInputInt("repeats")
@ -166,7 +159,6 @@ proc reminderUpdatePostHandler*() =
reply(Http303, [location("/")]) reply(Http303, [location("/")])
except CatchableError as e: except CatchableError as e:
echo e.msg echo e.msg
#reply(Http500)
discard assignGeneralErrorFR(e.msg) discard assignGeneralErrorFR(e.msg)
setFR() setFR()
reply(Http303, [location("/500")]) reply(Http303, [location("/500")])
@ -190,7 +182,6 @@ proc reminderDeletePostHandler*() =
reply(Http303, [location("/")]) reply(Http303, [location("/")])
except CatchableError as e: except CatchableError as e:
echo e.msg echo e.msg
#reply(Http500)
discard assignGeneralErrorFR(e.msg) discard assignGeneralErrorFR(e.msg)
setFR() setFR()
reply(Http303, [location("/500")]) reply(Http303, [location("/500")])

View File

@ -1,6 +1,6 @@
#[Copyright 2025 ITwrx. #[Copyright 2025 ITwrx.
This file is part of Simple Site Manager. This file is part of Forget-Me-Not.
Simple Site Manager is released under the GNU Affero General Public License 3.0. Forget-Me-Not is released under the GNU Affero General Public License 3.0.
See COPYING or <https://www.gnu.org/licenses/> for details.]# See COPYING or <https://www.gnu.org/licenses/> for details.]#
import guildenstern/httpserver, "../helpers/reminder", "../helpers/form" import guildenstern/httpserver, "../helpers/reminder", "../helpers/form"

View File

@ -1,6 +1,6 @@
#[Copyright 2025 ITwrx. #[Copyright 2025 ITwrx.
This file is part of Simple Site Manager. This file is part of Forget-Me-Not.
Simple Site Manager is released under the GNU Affero General Public License 3.0. Forget-Me-Not is released under the GNU Affero General Public License 3.0.
See COPYING or <https://www.gnu.org/licenses/> for details.]# See COPYING or <https://www.gnu.org/licenses/> for details.]#
import guildenstern/httpserver, "../models/user_session", "../helpers/form" import guildenstern/httpserver, "../models/user_session", "../helpers/form"