Moving JSON Responses to a standard Response object

Added cursor:pointer styling to dropdown menus
pull/24/head
Jordan 2014-06-01 22:30:23 -05:00
parent 3dd22e8d7c
commit 31aa5614a0
4 changed files with 12 additions and 12 deletions

View File

@ -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) {

View File

@ -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)
}
}

View File

@ -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 {

View File

@ -123,4 +123,8 @@
.modal-lg {
width: 900px;
}
}
.dropdown-menu > li > a {
cursor:pointer;
}