<%inherit file="/user/settings.html" />
<%namespace name="forms" file="/forms.html"/>
<%namespace name="components" file="/components.html"/>


<%block name="settings_content">
${tiles.user.header(c.page_user)}
<form class="well" method="POST" enctype="multipart/form-data">

    <input type="hidden" name="_method" value="PUT" />

    ${h.field_token()|n}

    ${components.flashmessages()}

    <h2>${_(u'Login settings')}</h2>

    %if h.user.can_change_password(c.page_user):
    <fieldset>
      <legend>${_("Password")}</legend>
      <p class="info">${_("Select a new password or leave the fields blank to keep your old one.")}</p>
      <div class="input_wrapper">
        <label for="password_change">${_("Password:")}</label>
        <input type="password" name="password_change" autocomplete="off" />
      </div>
      <div class="input_wrapper">
        <label for="password_confirm">${_("Password (confirm):")}</label>
        <input type="password" name="password_confirm" autocomplete="off" />
      </div>
    </fieldset>
    %endif


    %if 'openid' in h.allowed_login_types() or 'facebook' in h.allowed_login_types():
    <fieldset>
      <legend>${_("Single sign-on services")}</legend>
      <p class="info">${_("Single sign-on services allow you to use a single login on many web sites.")}</p>
      %if not len(c.page_user.openids) and not h.velruse.is_user_connected_to_facebook():
        <div class="infobox">
            ${_("There are no associated single sign-on services.")}
        </div>
      %else:
        <div class="input_wrapper">
          <table border="0" width="100%">
              %for openid in c.page_user.openids:
              <tr>
                  <td>${_("OpenID:")} <code>${openid.identifier}</code></td>
                  <td><a href="${h.base_url('/openid/revoke', query_params={'id': openid.id})}&amp;${h.url_token()}">${_("remove")}</a></td>
              </tr>
              %endfor
              <tr>
                  %if 'facebook' in h.allowed_login_types() and h.velruse.is_user_connected_to_facebook():
                  <td>Facebook</td>
                  <td><a href="${h.base_url('/velruse/revoke', query_params={'id': h.velruse.facebook_account().id})}&amp;${h.url_token()}">${_("remove")}</a></td>
                  %endif
              </tr>
          </table>
        </div>
      %endif
      <a class="add" href="/openid/connect">${_("Connect to single sign-on service")}</a>
    </fieldset>
    %endif

    ${components.savebox(cancel_url=None)}

</form>

</%block>
