{{template "base" .}}

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

{{define "page_body"}}

<div class="card shadow mb-4">
    <div class="card-header py-3">
        <h6 class="m-0 font-weight-bold text-primary">Change password</h6>
    </div>
    <div class="card-body">
        {{if .PwdError}}
        <div class="card mb-4 border-left-warning">
            <div class="card-body text-form-error">{{.PwdError}}</div>
        </div>
        {{end}}
        <form id="user_form" action="{{.ChangePwdURL}}" method="POST" autocomplete="off">
            <div class="form-group row">
                <label for="idCurrentPassword" class="col-sm-2 col-form-label">Current password</label>
                <div class="col-sm-10">
                    <input type="password" class="form-control" id="idCurrentPassword" name="current_password" required>
                </div>
            </div>

            <div class="form-group row">
                <label for="idNewPassword1" class="col-sm-2 col-form-label">New password</label>
                <div class="col-sm-10">
                    <input type="password" class="form-control" id="idNewPassword1" name="new_password1" required>
                </div>
            </div>

            <div class="form-group row">
                <label for="idNewPassword2" class="col-sm-2 col-form-label">Confirm password</label>
                <div class="col-sm-10">
                    <input type="password" class="form-control" id="idNewPassword2" name="new_password2" required>
                </div>
            </div>

            <input type="hidden" name="_form_token" value="{{.CSRFToken}}">
            <button type="submit" class="btn btn-primary float-right mt-3 px-5 px-3">Change my password</button>
        </form>
    </div>
</div>
{{if .LoggedUser.CanManagePublicKeys}}
<div class="card shadow mb-4">
    <div class="card-header py-3">
        <h6 class="m-0 font-weight-bold text-primary">Manage public keys</h6>
    </div>
    <div class="card-body">
        {{if .KeyError}}
        <div class="card mb-4 border-left-warning">
            <div class="card-body text-form-error">{{.KeyError}}</div>
        </div>
        {{end}}
        <form id="key_form" action="{{.ManageKeysURL}}" method="POST">

            <div class="form-group row">
                <label for="idPublicKeys" class="col-sm-2 col-form-label">Keys</label>
                <div class="col-sm-10">
                    <textarea class="form-control" id="idPublicKeys" name="public_keys" rows="3"
                        aria-describedby="pkHelpBlock">{{range .PublicKeys}}{{.}}&#10;{{end}}</textarea>
                    <small id="pkHelpBlock" class="form-text text-muted">
                        One public key per line
                    </small>
                </div>
            </div>

            <input type="hidden" name="_form_token" value="{{.CSRFToken}}">
            <button type="submit" class="btn btn-primary float-right mt-3 px-5 px-3">Submit</button>
        </form>
    </div>
</div>
{{end}}
{{end}}