diff --git a/.env b/.env index 915f7270..c4e717f2 100644 --- a/.env +++ b/.env @@ -44,7 +44,7 @@ MF_EMAIL_USERNAME=18bf7f70705139 MF_EMAIL_PASSWORD=2b0d302e775b1e MF_EMAIL_FROM_ADDRESS=from@example.com MF_EMAIL_FROM_NAME=Example -MF_EMAIL_TEMPLATE=/resetPasswEmail.tmpl +MF_EMAIL_TEMPLATE=email.tmpl ### Token utility MF_TOKEN_SECRET=some_random_bytes diff --git a/cmd/users/main.go b/cmd/users/main.go index 4cce8261..61544897 100644 --- a/cmd/users/main.go +++ b/cmd/users/main.go @@ -65,7 +65,7 @@ const ( defEmailPassword = "" defEmailFromAddress = "" defEmailFromName = "" - defEmailTemplate = "../configs/resetPasswEmail.tmpl" + defEmailTemplate = "email.tmpl" defTokenSecret = "mainflux-secret" defTokenDuration = "5" diff --git a/configs/resetPasswEmail.tmpl b/configs/resetPasswEmail.tmpl deleted file mode 100644 index c2e99d99..00000000 --- a/configs/resetPasswEmail.tmpl +++ /dev/null @@ -1,7 +0,0 @@ -To: {{.To}} -From: {{.From}} -Subject: {{.Subject}} -{{.Header}} -{{.Content}} -{{.Footer}} - diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 587f095b..ac5a1183 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -67,7 +67,7 @@ services: image: mainflux/users:latest container_name: mainflux-users volumes: - - ../users/emailer/templates/${MF_EMAIL_TEMPLATE}:${MF_EMAIL_TEMPLATE} + - ./users/emailer/templates/${MF_EMAIL_TEMPLATE}:/${MF_EMAIL_TEMPLATE} depends_on: - users-db expose: @@ -91,10 +91,10 @@ services: MF_EMAIL_PASSWORD: ${MF_EMAIL_PASSWORD} MF_EMAIL_FROM_ADDRESS: ${MF_EMAIL_FROM_ADDRESS} MF_EMAIL_FROM_NAME: ${MF_EMAIL_FROM_NAME} + MF_EMAIL_TEMPLATE: ${MF_EMAIL_TEMPLATE} MF_TOKEN_SECRET: ${MF_TOKEN_SECRET} MF_TOKEN_DURATION: ${MF_TOKEN_DURATION} MF_TOKEN_RESET_ENDPOINT: ${MF_TOKEN_RESET_ENDPOINT} - MF_EMAIL_TEMPLATE: ${MF_EMAIL_TEMPLATE} ports: - ${MF_USERS_HTTP_PORT}:${MF_USERS_HTTP_PORT} networks: diff --git a/users/emailer/templates/resetPasswEmail.tmpl b/docker/users/emailer/templates/email.tmpl similarity index 100% rename from users/emailer/templates/resetPasswEmail.tmpl rename to docker/users/emailer/templates/email.tmpl diff --git a/scripts/run.sh b/scripts/run.sh index b3d1b61b..d3287e4c 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -38,7 +38,7 @@ done ### # Users ### -MF_USERS_LOG_LEVEL=info $BUILD_DIR/mainflux-users & +MF_USERS_LOG_LEVEL=info MF_EMAIL_TEMPLATE=../docker/users/emailer/templates/email.tmpl $BUILD_DIR/mainflux-users & ### # Things diff --git a/users/README.md b/users/README.md index 1046bf05..40d007e1 100644 --- a/users/README.md +++ b/users/README.md @@ -41,9 +41,9 @@ default values. | MF_EMAIL_PASSWORD | Mail server password | | | MF_EMAIL_FROM_ADDRESS | Email "from" address | | | MF_EMAIL_FROM_NAME | Email "from" name | | -| MF_TOKEN_SECRET | Token secret for signing token used for password reset | | +| MF_EMAIL_TEMPLATE | Email template for sending emails with password reset link | email.tmpl | +| MF_TOKEN_SECRET | Password reset token signing secret | | | MF_TOKEN_DURATION | Token duration in minutes | 5 | -| MF_TOKEN_DEBUG_LEVEL | Token util debug level | info | | MF_TOKEN_RESET_ENDPOINT | Password request reset endpoint, for constructing link | /reset-request | ## Deployment @@ -84,9 +84,9 @@ services: MF_EMAIL_PASSWORD: [MF_EMAIL_PASSWORD] MF_EMAIL_FROM_ADDRESS: [MF_EMAIL_FROM_ADDRESS] MF_EMAIL_FROM_NAME: [MF_EMAIL_FROM_NAME] + MF_EMAIL_TEMPLATE: [MF_EMAIL_TEMPLATE] MF_TOKEN_SECRET: [MF_TOKEN_SECRET] MF_TOKEN_DURATION: [MF_TOKEN_DURATION] - MF_TOKEN_DEBUG_LEVEL: [MF_TOKEN_DEBUG_LEVEL] MF_TOKEN_RESET_ENDPOINT: [MF_TOKEN_RESET_ENDPOINT] ``` @@ -105,9 +105,11 @@ make users make install # set the environment variables and run the service -MF_USERS_LOG_LEVEL=[Users log level] MF_USERS_DB_HOST=[Database host address] MF_USERS_DB_PORT=[Database host port] MF_USERS_DB_USER=[Database user] MF_USERS_DB_PASS=[Database password] MF_USERS_DB=[Name of the database used by the service] MF_USERS_DB_SSL_MODE=[SSL mode to connect to the database with] MF_USERS_DB_SSL_CERT=[Path to the PEM encoded certificate file] MF_USERS_DB_SSL_KEY=[Path to the PEM encoded key file] MF_USERS_DB_SSL_ROOT_CERT=[Path to the PEM encoded root certificate file] MF_USERS_HTTP_PORT=[Service HTTP port] MF_USERS_GRPC_PORT=[Service gRPC port] MF_USERS_SECRET=[String used for signing tokens] MF_USERS_SERVER_CERT=[Path to server certificate] MF_USERS_SERVER_KEY=[Path to server key] MF_JAEGER_URL=[Jaeger server URL] $GOBIN/mainflux-users +MF_USERS_LOG_LEVEL=[Users log level] MF_USERS_DB_HOST=[Database host address] MF_USERS_DB_PORT=[Database host port] MF_USERS_DB_USER=[Database user] MF_USERS_DB_PASS=[Database password] MF_USERS_DB=[Name of the database used by the service] MF_USERS_DB_SSL_MODE=[SSL mode to connect to the database with] MF_USERS_DB_SSL_CERT=[Path to the PEM encoded certificate file] MF_USERS_DB_SSL_KEY=[Path to the PEM encoded key file] MF_USERS_DB_SSL_ROOT_CERT=[Path to the PEM encoded root certificate file] MF_USERS_HTTP_PORT=[Service HTTP port] MF_USERS_GRPC_PORT=[Service gRPC port] MF_USERS_SECRET=[String used for signing tokens] MF_USERS_SERVER_CERT=[Path to server certificate] MF_USERS_SERVER_KEY=[Path to server key] MF_JAEGER_URL=[Jaeger server URL] MF_EMAIL_DRIVER=[Mail server driver smtp] MF_EMAIL_HOST=[Mail server host] MF_EMAIL_PORT=[Mail server port] MF_EMAIL_USERNAME=[Mail server username] MF_EMAIL_PASSWORD=[Mail server password] MF_EMAIL_FROM_ADDRESS=[Email from address] MF_EMAIL_FROM_NAME=[Email from name] MF_EMAIL_TEMPLATE=[Email template file] MF_TOKEN_SECRET=[Password reset token signing secret] MF_TOKEN_DURATION=[Password reset token duration] MF_TOKEN_RESET_ENDPOINT=[Password reset token endpoint] $GOBIN/mainflux-users ``` +If `MF_EMAIL_TEMPLATE` doesn't point to any file service will function but password reset functionality will not work. + ## Usage For more information about service capabilities and its usage, please check out