--amend
alex wennerberg alex@alexwennerberg.com
Sat, 12 Dec 2020 12:02:01 -0800
3 files changed,
33 insertions(+),
4 deletions(-)
M
admin.go
→
admin.go
@@ -70,7 +70,14 @@ return nil
} func activateUser(username string) error { - _, err := DB.Exec("UPDATE user SET active = true WHERE username = ?", username) + // Not ideal here + row := DB.QueryRow("SELECT email FROM user where username = ?", username) + var email string + err := row.Scan(&email) + if err != nil { + return err + } + _, err = DB.Exec("UPDATE user SET active = true WHERE username = ?", username) if err != nil { // TODO verify 1 row updated return err@@ -90,6 +97,17 @@ username = filepath.Clean(username)
os.Mkdir(path.Join(c.FilesDirectory, username), os.ModePerm) ioutil.WriteFile(path.Join(c.FilesDirectory, username, "index.gmi"), []byte(baseIndex), 0644) os.Mkdir(path.Join(c.FilesDirectory, username), os.ModePerm) + if c.SMTPUsername != "" { + SendEmail(email, "Welcome to Flounder!", fmt.Sprintf(`Hi + %s, Welcome to Flounder! You can now log into your account at + https://flounder.online/login -- For more information about + Flounder, check out https://admin.flounder.online/ + + Let me know if you have any questions, and have fun! + + Alex + `, username)) + } return nil }
M
example-config.toml
→
example-config.toml
@@ -1,5 +1,5 @@
# Used in HTML templates and titles -SiteTitle="flounder" +SiteTitle="demoflounder" # Include port if running locally Host="localhost:8165"@@ -9,7 +9,8 @@ HttpPort=8165
HttpsEnabled=false # Folder containing subfolders for each user's files -FilesDirectory="./files" +# Must be absolute path due to bug +FilesDirectory="/home/alex/dev/go-flounder/files" LogFile="./flounder.log" # Gemini autogenerates self-signed certs@@ -20,11 +21,18 @@ # Only required if HttpsEnabled=true
# TLSCertFile="./server.crt" # TLSKeyFile="./server.key" +# Optional SMTP -- to send notification emails to users on acct activation +# SMTPServer = mail.goodsite.com:587 +# SMTPUsername = myemail@coolplace.com +# SMTPPassword = hunter2 + # Templates and static files # Everything in the static subfolder will be served at / TemplatesDirectory="./templates" DBFile="./flounder.db" -MaxFileSize=128000 # 128 KB +MaxFileBytes=128000 # 128 KB +MaxUserBytes=10000000 # 10 MB + OkExtensions=[".gmi", ".txt", ".jpg", ".jpeg", ".gif", ".png", ".svg", ".webp", ".midi", ".json", ".csv", ".gemini", ".mp3", ".css", ".ttf", ".otf", ".woff", ".woff2"]