mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-01-11 17:18:09 +02:00
Show an inline error if the wrong password is given when deleting a repo
This commit is contained in:
parent
1e75162bc8
commit
d262ffa1ab
@ -274,7 +274,7 @@ func RepoDelete(w http.ResponseWriter, r *http.Request, u *User, repo *Repo) err
|
|||||||
// the user must confirm their password before deleting
|
// the user must confirm their password before deleting
|
||||||
password := r.FormValue("password")
|
password := r.FormValue("password")
|
||||||
if err := u.ComparePassword(password); err != nil {
|
if err := u.ComparePassword(password); err != nil {
|
||||||
return err
|
return RenderError(w, err, http.StatusBadRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete the repo
|
// delete the repo
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<input class="form-control" type="password" name="password" value="" />
|
<input class="form-control" type="password" name="password" value="" />
|
||||||
</div>
|
</div>
|
||||||
|
<div class="alert alert-error hide" id="failureAlert"></div>
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<input class="btn btn-danger" id="submitButton" type="submit" value="Delete Repository" />
|
<input class="btn btn-danger" id="submitButton" type="submit" value="Delete Repository" />
|
||||||
<a class="btn btn-default" href="/{{.Repo.Slug}}/settings">Cancel</a>
|
<a class="btn btn-default" href="/{{.Repo.Slug}}/settings">Cancel</a>
|
||||||
@ -51,4 +52,27 @@
|
|||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ define "script" }}
|
{{ define "script" }}
|
||||||
|
<script>
|
||||||
|
document.forms[0].onsubmit = function(event) {
|
||||||
|
|
||||||
|
$("#failureAlert").hide();
|
||||||
|
$('#submitButton').button('loading');
|
||||||
|
|
||||||
|
var form = event.target
|
||||||
|
var formData = new FormData(form);
|
||||||
|
xhr = new XMLHttpRequest();
|
||||||
|
xhr.open('POST', form.action);
|
||||||
|
xhr.onload = function() {
|
||||||
|
if (this.status == 400) {
|
||||||
|
$("#failureAlert").text("The password you entered was incorrect.");
|
||||||
|
$("#failureAlert").show().removeClass("hide");
|
||||||
|
$('#submitButton').button('reset')
|
||||||
|
} else {
|
||||||
|
window.location.href = "/dashboard";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
xhr.send(formData);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
{{ end }}
|
{{ end }}
|
Loading…
Reference in New Issue
Block a user