mirror of https://github.com/gophish/gophish
Added better logging for campaign retrieval
parent
3ae09be989
commit
1d8ac6f9f3
|
@ -10,14 +10,14 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
ctx "github.com/gorilla/context"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/jinzhu/gorm"
|
||||
"github.com/jordan-wright/email"
|
||||
"github.com/gophish/gophish/auth"
|
||||
"github.com/gophish/gophish/models"
|
||||
"github.com/gophish/gophish/util"
|
||||
"github.com/gophish/gophish/worker"
|
||||
ctx "github.com/gorilla/context"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/jinzhu/gorm"
|
||||
"github.com/jordan-wright/email"
|
||||
)
|
||||
|
||||
// Worker is the worker that processes phishing events and updates campaigns.
|
||||
|
@ -92,6 +92,7 @@ func API_Campaigns_Id(w http.ResponseWriter, r *http.Request) {
|
|||
id, _ := strconv.ParseInt(vars["id"], 0, 64)
|
||||
c, err := models.GetCampaign(id, ctx.Get(r, "user_id").(int64))
|
||||
if err != nil {
|
||||
Logger.Println(err)
|
||||
JSONResponse(w, models.Response{Success: false, Message: "Campaign not found"}, http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -117,21 +117,28 @@ func GetCampaign(id int64, uid int64) (Campaign, error) {
|
|||
c := Campaign{}
|
||||
err := db.Where("id = ?", id).Where("user_id = ?", uid).Find(&c).Error
|
||||
if err != nil {
|
||||
Logger.Printf("%s: campaign not found\n", err)
|
||||
return c, err
|
||||
}
|
||||
err = db.Model(&c).Related(&c.Results).Error
|
||||
if err != nil {
|
||||
Logger.Printf("%s: results not found for campaign\n", err)
|
||||
return c, err
|
||||
}
|
||||
err = db.Model(&c).Related(&c.Events).Error
|
||||
if err != nil {
|
||||
Logger.Printf("%s: events not found for campaign\n", err)
|
||||
return c, err
|
||||
}
|
||||
err = db.Table("templates").Where("id=?", c.TemplateId).Find(&c.Template).Error
|
||||
if err != nil {
|
||||
Logger.Printf("%s: template not found for campaign\n", err)
|
||||
return c, err
|
||||
}
|
||||
err = db.Table("pages").Where("id=?", c.PageId).Find(&c.Page).Error
|
||||
if err != nil {
|
||||
Logger.Printf("%s: page not found for campaign\n", err)
|
||||
}
|
||||
return c, err
|
||||
}
|
||||
|
||||
|
@ -207,6 +214,7 @@ func PostCampaign(c *Campaign, uid int64) error {
|
|||
|
||||
//DeleteCampaign deletes the specified campaign
|
||||
func DeleteCampaign(id int64) error {
|
||||
Logger.Printf("Deleting campaign %d\n", id)
|
||||
// Delete all the campaign results
|
||||
err := db.Where("campaign_id=?", id).Delete(&Result{}).Error
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue