{# -*- coding: utf-8 -*-

  This file is part of Invenio.
  Copyright (C) 2015-2018 CERN.

  Invenio is free software; you can redistribute it and/or modify it
  under the terms of the MIT License; see LICENSE file for more details.
#}
{%- 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 %}
