<!--
Copyright (C) 2023 Nicola Murino

This WebUI uses the KeenThemes Mega Bundle, a proprietary theme:

https://keenthemes.com/products/templates-mega-bundle

KeenThemes HTML/CSS/JS components are allowed for use only within the
SFTPGo product and restricted to be used in a resealable HTML template
that can compete with KeenThemes products anyhow.

This WebUI is allowed for use only within the SFTPGo product and
therefore cannot be used in derivative works/products without an
explicit grant from the SFTPGo Team (support@sftpgo.com).
-->
{{template "base" .}}

{{- define "title"}}{{.Title}}{{- end}}

{{- define "page_body"}}
<div class="card shadow-sm">
    <div class="card-header bg-light">
        <h3 class="card-title text-primary">Change password</h3>
    </div>
    <div class="card-body">
        {{- template "errmsg" .Error}}
        <form id="change_pwd_form" action="{{.CurrentURL}}" method="POST" autocomplete="off">
            <div class="form-group row">
                <label class="col-md-3 col-form-label required">Current password</label>
                <div class="col-md-9">
                    <input type="password" class="form-control" placeholder="" name="current_password"
                        spellcheck="false" required />
                </div>
            </div>
            <div class="form-group row mt-10">
                <label class="col-md-3 col-form-label required">New password</label>
                <div class="col-md-9">
                    <input type="password" class="form-control" placeholder="" name="new_password1"
                        autocomplete="new-password" spellcheck="false" required />
                </div>
            </div>
            <div class="form-group row mt-10">
                <label class="col-md-3 col-form-label required">Confirm password</label>
                <div class="col-md-9">
                    <input type="password" class="form-control" placeholder="" name="new_password2"
                        autocomplete="new-password" spellcheck="false" required />
                </div>
            </div>
            <div class="d-flex justify-content-end mt-12">
                <input type="hidden" name="_form_token" value="{{.CSRFToken}}">
                <button type="submit" id="form_submit" class="btn btn-primary px-10">
                    <span class="indicator-label">
                        Submit
                    </span>
                    <span class="indicator-progress">
                        Please wait... <span class="spinner-border spinner-border-sm align-middle ms-2"></span>
                    </span>
                </button>
            </div>
        </form>
    </div>
</div>
{{end}}

{{- define "extra_js"}}
<script type="text/javascript" {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}}>
    KTUtil.onDOMContentLoaded(function () {
        $('#change_pwd_form').submit(function (event) {
            let submitButton = document.querySelector('#form_submit');
            submitButton.setAttribute('data-kt-indicator', 'on');
            submitButton.disabled = true;
        });
    });
</script>
{{- end}}