mirror of https://github.com/gophish/gophish
Moving JSON Responses to a standard Response object
Added cursor:pointer styling to dropdown menuspull/24/head
parent
3dd22e8d7c
commit
31aa5614a0
|
@ -255,7 +255,7 @@ func API_Templates_Id(w http.ResponseWriter, r *http.Request) {
|
|||
if checkError(err, w, "Error deleting group", http.StatusInternalServerError) {
|
||||
return
|
||||
}
|
||||
writeJSON(w, []byte("{\"success\" : \"true\"}"))
|
||||
writeJSON(w, models.Response{Success: true, Message: "Template Deleted Successfully"})
|
||||
case r.Method == "PUT":
|
||||
_, err := models.GetTemplate(id, ctx.Get(r, "user_id").(int64))
|
||||
if checkError(err, w, "No group found", http.StatusNotFound) {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package controllers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"net/http"
|
||||
|
@ -95,7 +94,6 @@ func Register(w http.ResponseWriter, r *http.Request) {
|
|||
m = "Unknown error - please try again"
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println(m)
|
||||
session.AddFlash(models.Flash{
|
||||
Type: "danger",
|
||||
Message: m,
|
||||
|
@ -131,10 +129,7 @@ func Settings(w http.ResponseWriter, r *http.Request) {
|
|||
switch {
|
||||
case r.Method == "POST":
|
||||
err := auth.ChangePassword(r)
|
||||
msg := struct {
|
||||
Message string `json:"message"`
|
||||
Success bool `json:"success"`
|
||||
}{Message: "Settings Updated Successfully", Success: true}
|
||||
msg := models.Response{Success: true, Message: "Settings Updated Successfully"}
|
||||
if err == auth.ErrInvalidPassword {
|
||||
msg.Message = "Invalid Password"
|
||||
msg.Success = false
|
||||
|
@ -142,11 +137,7 @@ func Settings(w http.ResponseWriter, r *http.Request) {
|
|||
msg.Message = "Unknown Error Occured"
|
||||
msg.Success = false
|
||||
}
|
||||
msgj, err := json.MarshalIndent(msg, "", " ")
|
||||
if checkError(err, w, "Error marshaling response", http.StatusInternalServerError) {
|
||||
return
|
||||
}
|
||||
writeJSON(w, msgj)
|
||||
writeJSON(w, msg)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,11 @@ type Flash struct {
|
|||
Message string
|
||||
}
|
||||
|
||||
type Response struct {
|
||||
Message string `json:"message"`
|
||||
Success bool `json:"success"`
|
||||
}
|
||||
|
||||
// Setup initializes the Conn object
|
||||
// It also populates the Gophish Config object
|
||||
func Setup() error {
|
||||
|
|
|
@ -124,3 +124,7 @@
|
|||
width: 900px;
|
||||
}
|
||||
}
|
||||
|
||||
.dropdown-menu > li > a {
|
||||
cursor:pointer;
|
||||
}
|
Loading…
Reference in New Issue