diff --git a/controllers/route.go b/controllers/route.go index ef67697c..e49c6287 100644 --- a/controllers/route.go +++ b/controllers/route.go @@ -268,9 +268,13 @@ func Settings(w http.ResponseWriter, r *http.Request) { if err == auth.ErrInvalidPassword { msg.Message = "Invalid Password" msg.Success = false + JSONResponse(w, msg, http.StatusBadRequest) + return } else if err != nil { msg.Message = "Unknown Error Occured" msg.Success = false + JSONResponse(w, msg, http.StatusBadRequest) + return } JSONResponse(w, msg, http.StatusOK) } diff --git a/static/js/app/settings.js b/static/js/app/settings.js new file mode 100644 index 00000000..36fd712a --- /dev/null +++ b/static/js/app/settings.js @@ -0,0 +1,24 @@ +$(document).ready(function(){ + $("#apiResetForm").submit(function(e){ + $.post("/api/reset", $(this).serialize()) + .done(function(data){ + api_key = data.data + successFlash(data.message) + $("#api_key").val(api_key) + }) + .fail(function(data){ + errorFlash(data.message) + }) + return false + }) + $("#settingsForm").submit(function(e){ + $.post("/settings", $(this).serialize()) + .done(function(data){ + successFlash(data.message) + }) + .fail(function(data){ + errorFlash(data.responseJSON.message) + }) + return false + }) +}) diff --git a/static/js/gophish.js b/static/js/gophish.js index 9103cf9d..45d3c2ee 100644 --- a/static/js/gophish.js +++ b/static/js/gophish.js @@ -1,7 +1,7 @@ function errorFlash(message) { $("#flashes").empty() $("#flashes").append("
\ - " + message + "
" + " + message + "" ) } @@ -106,5 +106,4 @@ var api = { return query("/templates/" + id, "DELETE", {}) } } - } diff --git a/templates/settings.html b/templates/settings.html index d42ef5f8..91735d4a 100644 --- a/templates/settings.html +++ b/templates/settings.html @@ -31,17 +31,17 @@
-
+

-
+
- +