mirror of https://github.com/gophish/gophish
Fixed settings - can now reset password, api key.
parent
821e31164c
commit
fc2aa71e91
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
})
|
||||
})
|
|
@ -1,7 +1,7 @@
|
|||
function errorFlash(message) {
|
||||
$("#flashes").empty()
|
||||
$("#flashes").append("<div style=\"text-align:center\" class=\"alert alert-danger\">\
|
||||
<i class=\"fa fa-exclamation-circle\"></i>" + message + "</div>"
|
||||
<i class=\"fa fa-exclamation-circle\"></i> " + message + "</div>"
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -106,5 +106,4 @@ var api = {
|
|||
return query("/templates/" + id, "DELETE", {})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,17 +31,17 @@
|
|||
<div class="col-md-6">
|
||||
<input type="text" id="api_key" onclick="this.select();" value="{{.User.ApiKey}}" class="form-control" readonly/>
|
||||
</div>
|
||||
<form ng-submit="api_reset()">
|
||||
<form id="apiResetForm">
|
||||
<button class="btn btn-primary"><i class="fa fa-refresh" type="submit"></i> Reset</button>
|
||||
<input type="hidden" name="csrf_token" value="{{.Token}}"/>
|
||||
</form>
|
||||
</div>
|
||||
<br />
|
||||
<form ngsubmit="save_settings()" method="POST">
|
||||
<form id="settingsForm">
|
||||
<div class="row">
|
||||
<label for="username" class="col-sm-2 control-label form-label">Username:</label>
|
||||
<div class="col-md-6">
|
||||
<input type="text" id="username" class="form-control" value="{{.User.Username}}" />
|
||||
<input type="text" id="username" name="username" value="{{.User.Username}}" class="form-control" />
|
||||
</div>
|
||||
</div>
|
||||
<br />
|
||||
|
|
Loading…
Reference in New Issue