Skip to content

Commit

Permalink
add smtp test and captcha language init
Browse files Browse the repository at this point in the history
  • Loading branch information
zhyale committed May 9, 2021
1 parent c8a1b79 commit 159eaee
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion data/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var (
// IsPrimary i.e. Is Primary Node
IsPrimary bool
// Version of JANUSEC
Version = "1.2.0"
Version = "1.2.1"
// NodeKey share with all nodes
NodeKey []byte
)
Expand Down
2 changes: 2 additions & 0 deletions gateway/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ func AdminAPIHandlerFunc(w http.ResponseWriter, r *http.Request) {
obj, err = data.UpdateCAS2Config(param, clientIP, authUser)
case "get_license":
obj, err = nil, nil
case "test_smtp":
obj, err = nil, TestSMTP(r)
default:
//fmt.Println("undefined action")
obj = nil
Expand Down
23 changes: 23 additions & 0 deletions gateway/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ package gateway
import (
"context"
"crypto/tls"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
Expand Down Expand Up @@ -671,3 +672,25 @@ func sendOfflineNotification(app *models.Application, dest string) {
func Test(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Done"))
}

// TestSMTP ...
func TestSMTP(r *http.Request) error {
var smtpTestReq models.SMTPTestRequest
err := json.NewDecoder(r.Body).Decode(&smtpTestReq)
if err != nil {
utils.DebugPrintln("TestSMTP Decode", err)
}
defer r.Body.Close()
smtpSetting := smtpTestReq.Object
if len(data.NodeSetting.SMTP.AdminEmails)==0 {
data.NodeSetting.SMTP.AdminEmails = data.DAL.GetAppAdminEmails()
}
go utils.SendEmail(smtpSetting.SMTPServer,
smtpSetting.SMTPPort,
smtpSetting.SMTPAccount,
smtpSetting.SMTPPassword,
data.NodeSetting.SMTP.AdminEmails,
"[JANUSEC] Test SMTP",
"This is a test email to application administrators.")
return nil
}
6 changes: 6 additions & 0 deletions models/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,9 @@ type NodeShareSetting struct {
// SMTP
SMTP *SMTPSetting `json:"smtp"`
}

// SMTPTestRequest for SMTP test
type SMTPTestRequest struct {
Action string `json:"action"`
Object *SMTPSetting `json:"object"`
}
2 changes: 1 addition & 1 deletion release_batch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ printf "Creating installation package\n"
printf "Checklist:\n"
printf "* Angular Admin Version Check. \n"
printf "* Janusec Version Check. \n"
version="1.2.0"
version="1.2.1"
printf "Version: ${version} \n"

read -r -p "Are You Sure? [Y/n] " option
Expand Down

0 comments on commit 159eaee

Please sign in to comment.