mirror of
https://github.com/ProjectSegfault/publapi.git
synced 2024-09-08 04:45:33 +05:30
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.
|
||||
|
||||
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
|
||||
Currently, PublAPI has only two routes, /users and /signup.
|
||||
|
@ -5,8 +5,7 @@ After=networking.target
|
||||
WorkingDirectory=/var/publapi
|
||||
User=publapi
|
||||
Group=publapi
|
||||
Environment=PUBLAPI_PORT=3000
|
||||
Environment=PUBLAPI_SHOUTRRRURL='matrix://user:password@host/'
|
||||
EnvironmentFile=/var/publapi/publapi.env
|
||||
ExecStart=/var/publapi/publapi
|
||||
RestartSec=5
|
||||
Restart=always
|
||||
|
@ -2,11 +2,10 @@ package pages
|
||||
|
||||
import (
|
||||
"github.com/ProjectSegfault/publapi/utils"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"os"
|
||||
|
||||
"github.com/containrrr/shoutrrr"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"os"
|
||||
"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")
|
||||
// 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
|
||||
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 {
|
||||
log.Error("Error sending notification to admins", err)
|
||||
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