Page MenuHomec4science

webaccount_login.html
No OneTemporary

File Metadata

Created
Wed, Jun 25, 06:16

webaccount_login.html

{#
## This file is part of Invenio.
## Copyright (C) 2012 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.
#}
{% from "_formhelpers.html" import render_field with context %}
{% extends "page.html" %}
{% set title = None %}
{% set activated_providers = config.CFG_OPENID_PROVIDERS * config.CFG_OPENID_AUTHENTICATION
+ config.CFG_OAUTH1_PROVIDERS * config.CFG_OAUTH1_AUTHENTICATION
+ config.CFG_OAUTH2_PROVIDERS * config.CFG_OAUTH2_AUTHENTICATION %}
{% block body %}
<div class="row">
<div class="span8 offset2">
<p class="lead text-center">{{ _("If you already have an account, please login using the form below.") }}</p>
<p class="text-center">{{ _("If you don't own an account yet, please %(x_url_open)sregister")|format(
x_url_open='<a href="'+url_for('webaccount.register')+'">')|safe }}
{{ _("%(x_url_close)s an internal account.")|format(x_url_close='</a>')|safe }}</p>
<hr/>
</div>
</div>
<div class="row">
<div class="span4 offset{{ '2' if activated_providers else '4' }}">
<legend>{{ _('Please Sign In') }}</legend>
<form action="{{ url_for('webaccount.login') }}" method="POST">
{{ form.referer }}
{{ form.login_method }}
{{ form.nickname(placeholder=_('Username or email'), class_="span4") }}
{{ form.password(placeholder=_('Password'), class_="span4") }}
<label class="checkbox">
{{ form.remember(class_="checkbox") }} {{ form.remember.label.text }}
</label>
{{ form.submit(class_="btn btn-info btn-block") }}
</form>
<p class="text-right">
<a href="{{ url_for('webaccount.lost') }}">
{{ _('Lost your password?') }}
</a>
</p>
</div>
{% macro external_login_button(provider, referer='', icon_size=48,
classes="", label="%(provider)s username") %}
{% if provider in config.CFG_OPENID_PROVIDERS %}
{% set type = 'openid' %}
{% elif provider in config.CFG_OAUTH2_PROVIDERS %}
{% set type = 'oauth2' %}
{% elif provider in config.CFG_OAUTH1_PROVIDERS %}
{% set type = 'oauth1' %}
{% else %}
{% set type = 'login' %}
{% endif %}
{% set handler = url_for('youraccount.' + type, provider=provider) %}
{% if referer %}
{% if not url_for('webaccount.login') in referer %}
{% set handler = url_for('youraccount.' + type, provider=provider, referer=referer) %}
{% endif %}
{% endif %}
<li class="{{ classes }}" id="{{ provider }}_login_button">
<a class="thumbnail" id="{{ provider }}_login"
rel="tooltip" title="{{ provider }}" data-placement="top"
href="{{ handler|safe }}">
<img class="external_provider {{ classes }}"
src="{{ url_for('static', filename="/img/%s_icon_%s.png"|format(provider, icon_size)) }}" />
</a>
</li>
{% endmacro %}
{% macro external_login_form(provider, referer='', icon_size=48,
classes="", label="%(provider)s username") %}
{#
Template of the login form for providers which need an username for
verification.
@param provider: The name of the provider
@type provider: str
@param referer: The referer URL - will be redirected upon after login
@type referer: str
@param icon_size: The size of the icon of the provider
@type icon_size: int
@param classes: Additional classes for the login form
@type classes: str
@param label: The label for text input.
@param label: str
@rtype: str
#}
{% if provider in config.CFG_OPENID_PROVIDERS %}
{% set type = 'openid' %}
{% elif provider in config.CFG_OAUTH2_PROVIDERS %}
{% set type = 'oauth2' %}
{% elif provider in config.CFG_OAUTH1_PROVIDERS %}
{% set type = 'oauth1' %}
{% else %}
{% set type = 'login' %}
{% endif %}
<li class="{{ classes }} login_form" id="{{ provider }}_verify_form">
<a class="thumbnail" id="{{ provider }}_login_img"
rel="tooltip" title="{{ provider }}" data-placement="top"
onclick="show_username_form('#{{ provider }}_verifier')" href="#{{ provider }}_verify_form">
<img class="external_provider {{ classes }}"
src="{{ url_for('static', filename="/img/%s_icon_%s.png"|format(provider, icon_size)) }}" />
</a>
<div class="login_content with_label" id="{{ provider }}_verifier" hidden="hidden">
<form method="get" accept-charset="UTF-8" action="{{ url_for('youraccount.' + type)|safe }}">
<input type="hidden" name="provider" value="{{ provider }}">
<input type="hidden" name="referer" value="{{ referer }}">
<input class="input-block-level" id="{{ provider }}_username_field"
style="background: url({{ url_for('static', filename="/img/%s_icon_%s.png"|format(provider, 24)) }});
background-repeat: no-repeat;
background-position: 2px center;
padding-left: 30px;
height: 30px;
box-sizing: border-box;"
type="text" name="identifier" value=""
placeholder="{{ label|format(provider=provider) }}">
<button class="btn btn-info btn-block" type="submit">
{{ _('Continue') }}&nbsp;<i class="icon-chevron-right icon-white"></i>
</button>
</form>
</div>
</li>
{% endmacro %}
{% macro construct_button(provider, size, button_class) %}
{% set c = config.CFG_OPENID_CONFIGURATIONS.get(provider, {}) %}
{% set identifier = c.get('identifier', '') %}
{% if "{0}" in identifier %}
{% set label = config.CFG_EXTERNAL_LOGIN_FORM_LABELS.get(provider, "%(provider)s username") %}
{{ external_login_form(provider, form.referer.data, size, button_class, _(label)) }}
{% else %}
{{ external_login_button(provider, form.referer.data, size, button_class) }}
{% endif %}
{% endmacro %}
{% if activated_providers %}
<style>
.auth_providers.thumbnails {
margin-left: 0px;
}
.auth_providers.thumbnails>li {
margin: 0px;
margin-right: 1px;
float: left!important;
}
.auth_providers .thumbnail {
padding: 0px;
border: none;
}
</style>
<div class="span1 hidden-phone" style="height: 200px; padding: 0px; display: block; float: left; width: 1px;
border-right: 1px solid #ccc;">&nbsp;</div>
<div class="span4">
<legend style="font-size: 90%;">{{ _('or Select Your Authentication Provider:') }}</legend>
<ul class="auth_providers thumbnails">
{% for provider in config.CFG_EXTERNAL_LOGIN_LARGE %}
{% if provider in activated_providers %}
{{ construct_button(provider, 48, "large") }}
{% endif %}
{% endfor %}
{% set providers = config.CFG_EXTERNAL_LOGIN_BUTTON_ORDER %}
{% if (activated_providers|length - CFG_EXTERNAL_LOGIN_LARGE|length) != providers|length %}
{# Not all the providers ordered. Add the unsorted ones to the end. #}
{% for provider in activated_providers|sort %}
{% if not provider in providers %}
{% do providers.append(provider) %}
{% endif %}
{% endfor %}
{% endif %}
{% for provider in providers %}
{% if not provider in config.CFG_EXTERNAL_LOGIN_LARGE %}
{{ construct_button(provider, 24, "") }}
{% endif %}
{% endfor %}
</ul>
<div id="form_field">
{% endif %}
</div>
{% endblock %}
{% block javascript %}
{{ super() }}
<script type="text/javascript">
function show_username_form(element) {
$('#form_field').html($(element).html())
return false
}
(function($) {
$('[rel=tooltip]').tooltip();
$('#nickname').popover({
title: '<strong>{{ _('Note') }}</strong>',
content: '{{ _('You can use your nickname or your email address to login.') }}',
trigger: 'focus',
html: true,
});
})(jQuery);
</script>
{% endblock %}

Event Timeline