Working on SendMail (currently NOT functional)

Added user model for kicks - we'll see if it finds a reason to stay
Setup /users and /settings routes
pull/24/head
Jordan Wright 2013-12-12 01:00:22 -06:00
parent a64b0c10c9
commit 5a5c9f600f
3 changed files with 25 additions and 1 deletions

View File

@ -4,6 +4,13 @@ import (
"net/smtp" "net/smtp"
) )
//Send sends an Email using a connection to Server.
//If a Username and Password are set for the Server, authentication will be attempted
//However, to support open-relays, authentication is optional.
func Send(email Email, server Server) { func Send(email Email, server Server) {
auth = smtp.PlainAuth("", server.User, server.Password, server.Server) auth := nil
if server.User != nil && server.Password != nil {
auth := smtp.PlainAuth("", server.User, server.Password, server.Host)
}
smtp.SendMail(server.Host, auth, email.From, email.To, Email.Body)
} }

View File

@ -19,3 +19,10 @@ type Config struct {
URL string `json:"url"` URL string `json:"url"`
SMTP SMTPServer `json:"smtp"` SMTP SMTPServer `json:"smtp"`
} }
type User struct {
Id string
Username string
Hash string
APIKey string
}

View File

@ -43,6 +43,8 @@ func createRouter() http.Handler {
router.HandleFunc("/login", Login) router.HandleFunc("/login", Login)
router.HandleFunc("/register", Register) router.HandleFunc("/register", Register)
router.HandleFunc("/campaigns", Base_Campaigns) router.HandleFunc("/campaigns", Base_Campaigns)
router.HandleFunc("/users", Users)
router.HandleFunc("/settings", Settings)
// Create the API routes // Create the API routes
api := router.PathPrefix("/api").Subrouter() api := router.PathPrefix("/api").Subrouter()
@ -69,6 +71,14 @@ func Base(w http.ResponseWriter, r *http.Request) {
renderTemplate(w, "dashboard") renderTemplate(w, "dashboard")
} }
func Users(w http.ResponseWriter, r *http.Request) {
renderTemplate(w, "users")
}
func Settings(w http.ResponseWriter, r *http.Request) {
renderTemplate(w, "settings")
}
func Base_Campaigns(w http.ResponseWriter, r *http.Request) { func Base_Campaigns(w http.ResponseWriter, r *http.Request) {
//session, _ := store.Get(r, "gophish") //session, _ := store.Get(r, "gophish")
renderTemplate(w, "dashboard") renderTemplate(w, "dashboard")