{#
# This file is part of Invenio.
# Copyright (C) 2015 CERN.
#
# Invenio is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# Invenio is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Invenio; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307, USA.
#
# In applying this license, CERN does not
# waive the privileges and immunities granted to it by virtue of its status
# as an Intergovernmental Organization or submit itself to any jurisdiction.
#}
{%- if config['ACCOUNTS'] %}
{%- if not current_user.is_authenticated %}
<form class="navbar-form navbar-right">
  <a href=" {{url_for_security('login', next=request.path)}}" class="btn btn-default"><i class="fa fa-sign-in"></i> {{_('Log in')}}</a>
  {% if security.registerable %}<a href=" {{url_for_security('register')}}" type="submit" class="btn btn-default btn-warning"><i class="fa fa-edit"></i> {{_('Sign up')}}</a>{% endif %}
</form>
{%- else %}
<div class="navbar-form navbar-right">
{%- if config['USERPROFILES'] %}
  <div class="btn-group">
    <a class="btn btn-default" href="{{ url_for('invenio_userprofiles.profile')}}">
      <i class="fa fa-user"></i> {{current_user.email}}
    </a>
    <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
      <span class="caret"></span>
    </button>
    <ul class="dropdown-menu" role="menu">
      {%- for item in current_menu.submenu('settings').children if item.visible %}
      <li><a href="{{ item.url }}">{{ item.text|safe }}</a></li>
      {%- endfor %}
      <li class="divider"></li>
      <li><a href="{{url_for_security('logout')}}"><i class="fa fa-sign-out"></i> {{_('Log out')}}</a></li>
    </ul>
  </div>
{%- else %}
<a href=" {{url_for_security('logout')}}" class="btn btn-default"><i class="fa fa-sign-out"></i> {{_('Log out')}}</a>
{%- endif %}
</div>
{%- endif %}
{%- endif %}
