send user email once registration is sent
This commit is contained in:
parent
52fe96a35b
commit
35c45a8126
@ -16,7 +16,7 @@ go build
|
|||||||
|
|
||||||
By default publapi listens on 127.0.0.1:3000. You can change the port with the environment variable PUBLAPI_PORT.
|
By default publapi listens on 127.0.0.1:3000. You can change the port with the environment variable PUBLAPI_PORT.
|
||||||
|
|
||||||
Additionally, you need to set the variable PUBLAPI_SHOUTRRRURL in order for signup notifications to work. Url Format can be found at https://containrrr.dev/shoutrrr/v0.5/services/matrix/
|
Additionally, you need to set the variable PUBLAPI_EMAIL_SHOUTRRRURL and PUBLAPI_NOTIFY_SHOUTRRRURL in order for signup notifications to work. URL Format can be found at https://containrrr.dev/shoutrrr/v0.5.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
Currently, PublAPI has only two routes, /users and /signup.
|
Currently, PublAPI has only two routes, /users and /signup.
|
||||||
|
@ -5,8 +5,7 @@ After=networking.target
|
|||||||
WorkingDirectory=/var/publapi
|
WorkingDirectory=/var/publapi
|
||||||
User=publapi
|
User=publapi
|
||||||
Group=publapi
|
Group=publapi
|
||||||
Environment=PUBLAPI_PORT=3000
|
EnvironmentFile=/var/publapi/publapi.env
|
||||||
Environment=PUBLAPI_SHOUTRRRURL='matrix://user:password@host/'
|
|
||||||
ExecStart=/var/publapi/publapi
|
ExecStart=/var/publapi/publapi
|
||||||
RestartSec=5
|
RestartSec=5
|
||||||
Restart=always
|
Restart=always
|
||||||
|
@ -2,11 +2,10 @@ package pages
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/ProjectSegfault/publapi/utils"
|
"github.com/ProjectSegfault/publapi/utils"
|
||||||
"github.com/gofiber/fiber/v2"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/containrrr/shoutrrr"
|
"github.com/containrrr/shoutrrr"
|
||||||
|
"github.com/gofiber/fiber/v2"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -44,8 +43,14 @@ func SignupPage(c *fiber.Ctx) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.Info("Registration request for " + username + " has been submitted by the frontend and has been written to /var/publapi/users/" + username + ".sh")
|
log.Info("Registration request for " + username + " has been submitted by the frontend and has been written to /var/publapi/users/" + username + ".sh")
|
||||||
|
// send notification to user that their reg request was sent
|
||||||
|
err = shoutrrr.Send(os.Getenv("PUBLAPI_EMAIL_SHOUTRRRURL")+email, "Hello "+username+",\nYour registration request has been sent.\nIt will take a maximum of 48 hours for the request to be processed.\nThank you for being part of the Project Segfault Pubnix.")
|
||||||
|
if err != nil {
|
||||||
|
log.Error("Error sending email to user", err)
|
||||||
|
return c.SendStatus(fiber.StatusInternalServerError)
|
||||||
|
}
|
||||||
// send notification to admins
|
// send notification to admins
|
||||||
err = shoutrrr.Send(os.Getenv("PUBLAPI_SHOUTRRRURL"), "New user signup! Please review /var/publapi/users/"+username+".sh to approve or deny the user. IP: "+ip+" Email: "+email)
|
err = shoutrrr.Send(os.Getenv("PUBLAPI_NOTIFY_SHOUTRRRURL"), "New user signup! Please review /var/publapi/users/"+username+".sh to approve or deny the user. IP: "+ip+" Email: "+email)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Error sending notification to admins", err)
|
log.Error("Error sending notification to admins", err)
|
||||||
return c.SendStatus(fiber.StatusInternalServerError)
|
return c.SendStatus(fiber.StatusInternalServerError)
|
||||||
|
3
publapi.env
Normal file
3
publapi.env
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
PUBLAPI_PORT=3000
|
||||||
|
PUBLAPI_NOTIFY_SHOUTRRRURL='matrix://pubnixbot:xxx@projectsegfau.lt/'
|
||||||
|
PUBLAPI_EMAIL_SHOUTRRRURL='smtp://pubnix%40projectsegfau.lt:xxx@mail.projectsegfau.lt:587/?auth=Plain&fromaddress=pubnix%40projectsegfau.lt&fromname=Project+Segfault+Pubnix&subject=Your+registration+request+for+the+Project+Segfault+pubnix+has+been+sent&toaddresses='
|
Loading…
Reference in New Issue
Block a user