{% extends "master.html" %}
{% from "_formhelper.html" import render_bootstrap_field %}
{% block title %}{{ user.user }}'s settings{% endblock %}
{% set tag = "users"%}
{% macro render_email(email, form, validated=True) %}
<div class="list-group-item {% if not validated %}disabled{% endif %}">
<span class="oi" data-glyph="envelope-closed"></span> {{ email.email }}
{% if validated %}
<form class="pull-xs-right" method="POST"
action="{{ url_for('ui_ns.remove_user_email') }}">
<input type="hidden" value="{{ email.email }}" name="email" />
{{ form.csrf_token }}
<button
onclick="return confirm('Do you really want to remove the email: {{ email.email }}?');"
title="Remove email" class="btn btn-sm btn-danger">
<span class="oi" data-glyph="trash"></span>
</button>
</form>
{% if email.email == user.default_email %}
<span class="text-muted pull-xs-right p-r-1">
<span class="oi" data-glyph="star" title="default email address" data-toggle="tooltip"></span>
</span>
{% else %}
<form style="display:inline;" method="POST"
action="{{ url_for('ui_ns.set_default_email') }}" id="default_mail">
<input type="hidden" value="{{ email.email }}" name="email" />
{{ form.csrf_token }}
<a class="pull-xs-right p-r-1" href="javascript:void(0);"
onclick="$(this).closest('form').submit();"
title="Set default email address">
<small>set as default</small>
</a>
</form>
{% endif %}
{% else %}
<div class="pull-xs-right">
<small>pending verification via email</small>
<form style="display:inline;" method="POST"
action="{{ url_for('ui_ns.reconfirm_email') }}" id="reconfirm_mail">
<input type="hidden" value="{{ email.email }}" name="email" />
{{ form.csrf_token }}
<button
onclick="$(this).closest('form').submit();"
title="Resend validation email" class="btn btn-sm btn-warning">
<span class="oi" data-glyph="loop-circular"></span>
</button>
</form>
</div>
{% endif %}
</div>
{% endmacro %}
{% block content %}
<div class="container p-t-3">
<div class="col-md-8 col-md-offset-2">
<div class="card m-b-3">
<div class="card-header">
Basic Information
</div>
<div class="card-block">
<fieldset class="form-group">
<label for="description"><strong>Username</strong></label>
<div>{{ user.user }}</div>
</fieldset>
<fieldset class="form-group">
<label for="description"><strong>Full Name</strong></label>
<div>{{ user.fullname }}</div>
</fieldset>
<fieldset class="form-group">
<label for="description"><strong>Avatar</strong></label>
<div>
<a> {{ g.fas_user.username | avatar(80) | safe }} </a>
<a class="btn btn-primary" href="https://www.libravatar.org/account/login/">
Change Avatar </a>
</div>
</fieldset>
</div>
</div>
<div class="card m-b-3">
<div class="card-header">
<strong>Email Addresses</strong>
<a class="btn btn-success btn-sm pull-xs-right" href="{{
url_for('ui_ns.add_user_email') }}">
Add Email
</a>
</div>
<div class="list-group list-group-flush">
{% for email in user.emails %}
{{ render_email(email, form) }}
{% endfor %}
{% for email in user.emails_pending %}
{{ render_email(email, form, validated=False) }}
{% endfor %}
</div>
</div>
{% if config.get('LOCAL_SSH_KEY', True) %}
<div class="card m-b-3">
<div class="card-header">
<strong>Authentication</strong>
</div>
<div class="card-block">
<form action="{{ url_for('ui_ns.user_settings') }}" method="post">
{{ render_bootstrap_field(form.ssh_key) }}
<p class="small">
For multiple keys, enter one per line.
</p>
<p class="buttons indent">
<input type="submit" class="btn btn-primary" value="Update">
<input type="button" class="btn btn-secondary" value="Cancel" class="button" onclick="history.back();">
{{ form.csrf_token }}
</p>
</form>
</div>
</div>
{% endif %}
<div class="card m-b-3">
<div class="card-header">
User settings
</div>
<div class="card-block">
<form action="{{ url_for('ui_ns.update_user_settings') }}" method="post">
{% for key in user.settings | sort %}
{% if user.settings[key] in [True, False, 'y'] %}
<div>
<label class="c-input c-checkbox">
<input id="{{ key }}" type="checkbox" value="y" name="{{ key }}" {%
if user.settings[key] -%}checked=""{%- endif -%}/>
<span class="c-indicator"></span>
Activate {{ key | replace('_', ' ') }}
</label>
</div>
{% else %}
<div class="form-inline">
<label for="{{ key }}">Activate {{ key | replace('_', ' ') }} :</label>
<input width="4em" class="form-control" id="{{ key }}" type="text" {%
if user.settings[key] %}value="{{ user.settings[key] }}"{%
endif %} name="{{ key }}" />
</div>
{% endif %}
{% endfor %}
</table>
<p class="p-t-2">
<input type="submit" class="btn btn-primary" value="Update">
{{ form.csrf_token }}
</p>
</form>
</div>
</div>
{% if config.get('PAGURE_AUTH')=='local' %}
<div class="card m-b-3">
<a href="{{ url_for('ui_ns.change_password', username=g.fas_user.username) }}">Change password</a>
</div>
{% endif %}
</div>
<div class="col-md-8 col-md-offset-2">
<div class="card" id="api-keys">
<div class="card-header">
<strong>API Keys</strong>
</div>
<div class="card-block">
<p>
API keys are tokens used to authenticate you on pagure. They can also
be used to grant access to 3rd party application to behave on all
projects in your name.
</p>
<p>
These are your personal tokens; they are not visible to others.
</p>
<p>
These keys are valid for <span class="strong">60</span> days.
</p>
<p>
These keys are private, make sure to store in a safe place and
do not share it.
</p>
</div>
{% if user.tokens %}
<ul class="list-group list-group-flush">
{% for token in user.tokens %}
{% if not token.project %}
<li class="list-group-item">
<div class="form-group">
<div class="input-group">
<div class="input-group-addon"><span class="oi" data-glyph="key"></span></div>
<input class="form-control" type="text" value="{{ token.id }}" readonly>
</div>
</div>
{% if token.expired %}
<span class="text-danger btn-align"><strong>Expired</strong> since {{ token.expiration.date() }}</span>
{% else %}
<span class="text-success btn-align"><strong>Valid</strong> until: {{ token.expiration.date() }}</span>
<form class="pull-xs-right" action="{{ url_for(
'ui_ns.revoke_api_user_token', token_id=token.id) }}"
method="post" class="icon">
<button class="btn btn-danger" type="submit"
onclick="return confirm('Are you sure to revoke this token ?'
+ '\nThis will break all application using it and '
+ 'cannot be un-done.');"
title="Revoke token">
<span class="oi" data-glyph="trash"></span> Revoke
</button>
{{ form.csrf_token }}
</form>
{% endif %}
<button type="button" class="btn btn-link"
data-toggle="modal" data-target="#acls{{ token.id }}">
ACLs
</button>
<div class="modal fade" id="acls{{ token.id }}" tabindex="-1"
role="dialog" aria-labelledby="ACLs" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
<span class="sr-only">Close</span>
</button>
<h4 class="modal-title" id="myModalLabel">ACLs</h4>
</div>
<div class="modal-body">
<ul>
{% for acl in token.acls_list_pretty %}
<li>{{ acl }}</li>
{% endfor %}
</ul>
</div>
</div>
</div>
</div>
</li>
{% endif %}
{% endfor %}
</ul>
{% endif %}
<div class="card-block">
<a href="{{ url_for('ui_ns.add_api_user_token') }}" method="post" class="icon">
<button class="btn btn-primary" type="submit"
title="Generate a new API token">
Create new key
</button>
</a>
</div>
</div>
</div>
<div class="col-md-8 col-md-offset-2">
<div class="card" id="force-logout">
<div class="card-header">
<strong>Force logout</strong>
</div>
<div class="card-block">
<p>
Click the "Force logout everywhere" to forcefully log out from every
current open session.
</p>
</div>
<div class="card-block">
<a href="{{ url_for('ui_ns.force_logout') }}" method="post" class="icon">
<button class="btn btn-primary" type="submit"
title="Log out all currently active sessions">
Log out all currently active sessions
</button>
</a>
</div>
</div>
</div>
</div>
{% endblock %}