diff --git a/db/main.go b/db/main.go index 0a2729ea..8b6b684e 100644 --- a/db/main.go +++ b/db/main.go @@ -19,6 +19,7 @@ import ( "github.com/pocketbase/pocketbase/plugins/migratecmd" "github.com/pocketbase/pocketbase/tools/filesystem" "github.com/pocketbase/pocketbase/tools/security" + "github.com/spf13/cast" "pocketbase/integrations/komoot" "pocketbase/integrations/strava" @@ -30,7 +31,7 @@ import ( const defaultMeiliMasterKey = "vODkljPcfFANYNepCHyDyGjzAMPcdHnrb6X5KyXQPWo" // verifySettings checks if the required environment variables are set. -// If they are not set, it logs an error and exits the program. +// If they are not set, it logs a warning. func verifySettings(app core.App) { encryptionKey := os.Getenv("POCKETBASE_ENCRYPTION_KEY") @@ -106,6 +107,8 @@ func setupEventHandlers(app *pocketbase.PocketBase, client meilisearch.ServiceMa app.OnRecordRequestEmailChangeRequest("users").BindFunc(changeUserEmailHandler()) app.OnServe().BindFunc(onBeforeServeHandler(client)) + + app.OnBootstrap().BindFunc(onBootstrapHandler()) } func createUserHandler(client meilisearch.ServiceManager) func(e *core.RecordEvent) error { @@ -586,6 +589,38 @@ func onBeforeServeHandler(client meilisearch.ServiceManager) func(se *core.Serve } +func onBootstrapHandler() func(se *core.BootstrapEvent) error { + return func(e *core.BootstrapEvent) error { + if err := e.Next(); err != nil { + return err + } + + if v := os.Getenv("POCKETBASE_SMTP_SENDER_ADRESS"); v != "" { + e.App.Settings().Meta.SenderAddress = v + } + if v := os.Getenv("POCKETBASE_SMTP_SENDER_NAME"); v != "" { + e.App.Settings().Meta.SenderName = v + } + if v := os.Getenv("POCKETBASE_SMTP_ENABLED"); v != "" { + e.App.Settings().SMTP.Enabled = cast.ToBool(v) + } + if v := os.Getenv("POCKETBASE_SMTP_HOST"); v != "" { + e.App.Settings().SMTP.Host = v + } + if v := os.Getenv("POCKETBASE_SMTP_PORT"); v != "" { + e.App.Settings().SMTP.Port = cast.ToInt(v) + } + if v := os.Getenv("POCKETBASE_SMTP_USERNAME"); v != "" { + e.App.Settings().SMTP.Username = v + } + if v := os.Getenv("POCKETBASE_SMTP_PASSWORD"); v != "" { + e.App.Settings().SMTP.Password = v + } + + return e.App.Save(e.App.Settings()) + } +} + func registerRoutes(se *core.ServeEvent, client meilisearch.ServiceManager) { se.Router.GET("/public/search/token", func(e *core.RequestEvent) error { searchRules := map[string]interface{}{ diff --git a/docs/src/content/docs/getting-started/configuration.md b/docs/src/content/docs/getting-started/configuration.md index 87a762c2..364d35ea 100644 --- a/docs/src/content/docs/getting-started/configuration.md +++ b/docs/src/content/docs/getting-started/configuration.md @@ -25,6 +25,13 @@ Since we use an unmodified installation of meilisearch you can use all variables | ----------------------------- | ----------------------------------------------------------------------------------- | --------- | | POCKETBASE_ENCRYPTION_KEY | Valid 32 character AES key. Used to encrypt secrets | | | POCKETBASE_CRON_SYNC_SCHEDULE | Valid cron expression. Sets how often trails are synced from 3rd party integrations | 0 2 * * * | +| POCKETBASE_SMTP_ENABLED | Enables or disables SMTP functionality. Accepted values are true or false | false | +| POCKETBASE_SMTP_SENDER_ADRESS | The email address used as the "From" address in outgoing emails | | +| POCKETBASE_SMTP_SENDER_NAME | The display name shown as the sender in outgoing emails | | +| POCKETBASE_SMTP_HOST | The hostname or IP address of the SMTP server | | +| POCKETBASE_SMTP_PORT | The port number used to connect to the SMTP server | | +| POCKETBASE_SMTP_USERNAME | The username used to authenticate with the SMTP server | | +| POCKETBASE_SMTP_PASSWORD | The password used to authenticate with the SMTP server | | ## Frontend diff --git a/docs/src/content/docs/guides/authentication.md b/docs/src/content/docs/guides/authentication.md index 4eca24e1..7ac8e461 100644 --- a/docs/src/content/docs/guides/authentication.md +++ b/docs/src/content/docs/guides/authentication.md @@ -76,5 +76,7 @@ To set up password reset emails you will need to access the PocketBase backend. Next in the pocketbase admin panel go to Settings -> Mail settings an enable "Use SMTP mail server". Enter the details of your SMTP server and send a test email to ensure your configuration is correct. On the same page you can also adjust the email template of the password reset email. +Alternatively, you can set these options via the respective [environment variables](/getting-started/configuration/#pocketbase). + ### Request password reset -Once the SMTP access is configured users can click the "Forgot password" link in the login form. After requesting the reset the user will receive an email with a unique link to reset their password. \ No newline at end of file +Once the SMTP access is configured, users can click the "Forgot password" link in the login form. After requesting the reset the user will receive an email with a unique link to reset their password. \ No newline at end of file diff --git a/docs/src/content/docs/guides/custom-categories.md b/docs/src/content/docs/guides/custom-categories.md index 84874f2c..0aaac9b4 100644 --- a/docs/src/content/docs/guides/custom-categories.md +++ b/docs/src/content/docs/guides/custom-categories.md @@ -12,7 +12,7 @@ To create backend access navigate to your docker-compose.yaml file and type: ``` docker compose exec -it db /pocketbase superuser upsert email@example.com myverysecurepassword ``` -Now, you will have access with the User" email@example.com and the Password "myverysecurepassword" to all tables in the backend and can modify the underlying data directly. +Now, you will have access with the user "email@example.com" and the password "myverysecurepassword" to all tables in the backend and can modify the underlying data directly. ## Modifying categories diff --git a/web/src/lib/i18n/locales/de.json b/web/src/lib/i18n/locales/de.json index 768510be..a2d55246 100644 --- a/web/src/lib/i18n/locales/de.json +++ b/web/src/lib/i18n/locales/de.json @@ -32,7 +32,7 @@ "by": "von", "can": "kann", "cancel": "Abbrechen", - "car": "", + "car": "Auto", "card": "{n, plural, =1 {Karte} other {Karten}}", "categories": "Kategorien", "category": "Kategorie", @@ -97,7 +97,7 @@ "elevation-loss": "Höhenunterschied (abw.)", "email": "Email", "email-updated": "E-Mail aktualisiert", - "email-verified": "", + "email-verified": "Email verifiziert", "empty-activities": "{username} hat noch keine Aktivitäten", "empty-bio": "{username} hat noch keine Biografie hinzugefügt", "empty-lists": "{username} hat keine öffentlichen Listen", @@ -139,7 +139,7 @@ "forgot-your-password": "Passwort vergessen?", "french": "Französisch", "from-file": "Aus einer Datei", - "from-photos": "", + "from-photos": "Aus Fotos", "from-url": "Aus einer URL", "german": "Deutsch", "get-position-from-exif": "Koordinaten aus EXIF Daten", @@ -152,7 +152,7 @@ "hero_section_1_text_alternative": "Speichere dein letztes Abenteuer, um loszulegen.", "hero_section_2_text": "Wusstest du schon? Du kannst nicht nur deine Wanderrouten speichern. Es gibt viele Kategorien für alle deine Abenteuer.", "hiking": "Wandern", - "home": "", + "home": "Home", "hungarian": "Ungarisch", "hybrid": "Hybrid", "icon": "Icon", @@ -321,11 +321,11 @@ "upload-gpx": "GPX hochladen", "upload-new-file": "Neue Datei hochladen", "uploaded": "hochgeladen", - "use-hills": "", + "use-hills": "Hügel einbeziehen", "use-roads": "Nutze Straßen", "username": "Nutzername", "view": "Ansehen", - "walking-speed": "", + "walking-speed": "Laufgeschwindigkeit", "waypoints": "{n, plural, =1 {Wegpunkt} other {Wegpunkte}}", "welcome_to": "Willkommen bei", "width": "Breite",