Commit b17f9027 authored by Olga Brani's avatar Olga Brani
Browse files

Bug fixes

Style improvents
Authorisation methods page
parent b655c9c1
......@@ -458,8 +458,6 @@ form.quotas-form legend span.info span { width:395px; }
.stats .green .img-wrap { background-position: -263px 7px; }
.projects .editable form textarea { width:70%; height:50px; max-width:70%; width:270px; height:120px;}
/* temp style to hide extra menu for groups */
.navigation ul+ul { display:none; }
table .msg-wrap { position:relative; }
table .msg-wrap .dialog { position:absolute; border:1px dashed #ccc; padding:15px; width:200px; bottom:30px; left:0; background:#fff; display:none; }
......@@ -487,8 +485,17 @@ form.quotas-form span.error-msg:hover em { background-position:-58px -3px; }
.content .how-it-works a.submit:focus { border-color: #B3B3B3}
.content .how-it-works a.submit:focus:hover { border-color: #55B577}
.auth_methods { margin:3em 0; }
.auth_methods .wrap { }
.auth_methods h2 { font-size:1.154em; }
.auth_methods table { width:100%; color:#222; margin:1em 0; }
.auth_methods table th { font-weight:normal; color:#3582AC }
\ No newline at end of file
.auth_methods ul { margin:1em 0; padding:0; list-style:none outside none; }
.auth_methods ul li { margin:0 0 1em 0; padding:0; list-style:none outside none; font-size:1.154em; }
.auth_methods ul li>a { padding-right:20px; background:url(../images/arrow-down_green.png) no-repeat center right; color:#55B577 }
.auth_methods ul li>a.up { background-image:url(../images/arrow-up_green.png); }
.auth_methods ul li .wrap { font-size:0.867em; margin-top:1em; display:none; }
.auth_methods ul li .actions a { margin-right:20px; }
.auth_methods ul li a.red { color:#F24E53; }
.auth_methods ul.notassigned { margin-top:3em; }
.auth_methods ul.notassigned li>a { background:transparent; color: #F89A1C}
.auth_methods .dialog-wrap { display:inline; position:relative; }
.auth_methods .dialog { background:#fff; border:1px dashed #ccc; position:absolute; bottom:30px; left:0; padding:15px; width:220px; display:none;}
.auth_methods .dialog .submit { min-width:30px; padding:5px 22px; }
.content input:-webkit-autofill { background: transparent; }
......@@ -288,6 +288,34 @@ $(document).ready(function() {
$('.hidden-submit .form-row.submit').show(500);
});
$('.auth_methods').find('li>a').click(function(e){
e.preventDefault();
$(this).siblings('.wrap').toggle('slow');
$(this).toggleClass('up');
});
$('.auth_methods a.red').click(function(e){
e.preventDefault();
$(this).siblings('.dialog').show();
})
$('.auth_methods .dialog .no').click( function(e){
e.preventDefault();
console.log($(this));
$(this).parents('.dialog').hide();
})
setTimeout(function() {
if ($('input#id_username').val()){
$('input#id_username').siblings('label').css('opacity','0');
};
if ($('input#id_password').val()){
$('input#id_password').siblings('label').css('opacity','0');
}
}, 100);
});
$(window).resize(function() {
......
{% extends "im/account_base.html" %}
{% block page.body %}
<div class="full bottom-bordered clearfix">
<div class="full clearfix">
<div class="lt-div">
<p>Invite someone else</p>
</div>
......@@ -22,7 +22,7 @@
</div>
<div class="full {% block innerpage.class %}{% endblock %}">
<div class="full full-dotted">
<h2>You have <em>{{ inviter.invitations }}</em> invitation{{ inviter.invitations|pluralize }} left.</h2>
{% if sent|length %}
......
......@@ -13,58 +13,64 @@
<input type="hidden" name="auth" value="{{ user.auth_token }}">
<input type="submit" class="submit altcol" value="UPDATE" />
</div>
</form>
<div class="full-dotted">
<div class="auth_methods">
<br /><br />
<div class="assigned">
<h4>Authentication methods</h4>
<p>You can login to your account using the following methods</p>
<ul class="auth_providers">
<h2>ENABLED AUTHENTICATION METHODS</h2>
<ul>
{% for provider in user_providers %}
<li>
<h2>
{{ provider.settings.title }}
<span class="actions" style="margin-left: 40px">
<a href="#">{{ provider.settings.title }}</a>
<div class="wrap">
<p>{{ provider.details_display }}</p>
<div class="actions">
{% for name, url in provider.settings.extra_actions %}
<a href="{{ url }}" title="{{ name }}">{{ name }}</a>
{% endfor %}
{% if provider.can_remove %}
<a href="{% url remove_auth_provider provider.pk %}" title="disble">Remove</a>
<div class="dialog-wrap">
<a href="#" title="disable" class="red">
Disable x</a>
<div class="dialog">Are you sure you want to disable this method?
<a href="{% url remove_auth_provider provider.pk %}" class="yes submit">Yes</a>&nbsp;&nbsp;&nbsp;<a href="#" class="no submit">No</a>
</div>
</div>
{% endif %}
</span>
</h2>
<p>{{ provider.details_display }}</p>
<br />
</div>
</div>
</li>
{% empty %}
<li>No available authentication methods</li>
{% endfor %}
</ul>
</div>
<div class="notassigned">
<p>You can add the following authentication methods to your account </p>
<ul class="auth_providers">
{% for provider in user_available_providers %}
<ul class="notassigned">
<li>
<h2><a href="{{ provider.add_url }}">{{ provider.title }}</a></h2>
<p>{{ provider.add_description }}</p>
<br />
</li>
<a href="#">+ Add new authentication method</a>
<div class="wrap">
{% for provider in user_available_providers %}
<p><a href="{{ provider.add_url }}">{{ provider.title }}</a> ( {{ provider.add_description }})</p>
{% empty %}
No available providers.
No available providers
{% endfor %}
</ul>
</div>
</li>
</ul>
</div>
</div>
</form>
<div class="full-dotted">
<ul class="options">
<li><a href="https://okeanos.grnet.gr/home/" class="blue">Back to ~okeanos ></a></li>
<li><a href="https://cyclades.okeanos.grnet.gr/ui/" class="blue">Take me to cyclades ></a></li>
<li><a href="https://pithos.okeanos.grnet.gr/ui/" class="blue">Take me to pithos+ ></a></li>
</ul>
<div class="two-cols-links">
<p><a href="{% url password_change %}">Change Password</a></p>
<p>
<a href="https://okeanos.grnet.gr/home/">Back to ~okeanos</a>
<a href="https://cyclades.okeanos.grnet.gr/ui/">Take me to cyclades</a>
<a href="https://pithos.okeanos.grnet.gr/ui/">Take me to pithos+</a>
</p>
</div>
{% endblock body %}
{% extends "im/account_base.html" %}
{% block body %}
<form action={%url edit_profile %} method="post" class="withlabels hidden-submit">{% csrf_token %}
{% with profile_form as form %}
{% include "im/form_render.html" %}
{% endwith %}
<div class="form-row submit">
<input type="hidden" name="next" value="{{ next }}">
<input type="hidden" name="auth" value="{{ user.auth_token }}">
<input type="submit" class="submit altcol" value="UPDATE" />
</div>
<div class="auth_methods">
<br /><br />
<div class="assigned">
<h2><a href="#">Available authentication methods</a></h2>
<p>You can login to your account using the following methods</p>
<ul class="auth_providers">
{% for provider in user_providers %}
<li>
<h2>
{{ provider.settings.title }}
<span class="actions" style="margin-left: 40px">
{% for name, url in provider.settings.extra_actions %}
<a href="{{ url }}" title="{{ name }}">{{ name }}</a>
{% endfor %}
{% if provider.can_remove %}
<a href="{% url remove_auth_provider provider.pk %}" title="disble">Remove</a>
{% endif %}
</span>
</h2>
<p>{{ provider.details_display }}</p>
<br />
</li>
{% empty %}
<li>No available authentication methods</li>
{% endfor %}
</ul>
</div>
<div class="notassigned">
<p>You can add the following authentication methods to your account </p>
<ul class="auth_providers">
{% for provider in user_available_providers %}
<li>
<h2><a href="{{ provider.add_url }}">{{ provider.title }}</a></h2>
<p>{{ provider.add_description }}</p>
<br />
</li>
{% empty %}
No available providers.
{% endfor %}
</ul>
</div>
</div>
</form>
<div class="two-cols-links">
<p><a href="{% url password_change %}">Change Password</a></p>
<p>
<a href="https://okeanos.grnet.gr/home/">Back to ~okeanos</a>
<a href="https://cyclades.okeanos.grnet.gr/ui/">Take me to cyclades</a>
<a href="https://pithos.okeanos.grnet.gr/ui/">Take me to pithos+</a>
</p>
</div>
{% endblock body %}
......@@ -57,6 +57,7 @@ from django.views.generic.create_update import (delete_object,
get_model_and_form_class)
from django.views.generic.list_detail import object_list
from django.core.xheaders import populate_xheaders
from django.core.exceptions import ValidationError, PermissionDenied
from django.template.loader import render_to_string
from django.views.decorators.http import require_http_methods
......@@ -64,7 +65,7 @@ from astakos.im.activation_backends import get_backend, SimpleBackend
from astakos.im.models import (AstakosUser, ApprovalTerms, AstakosGroup,
EmailChange, GroupKind, Membership,
RESOURCE_SEPARATOR)
RESOURCE_SEPARATOR, AstakosUserAuthProvider)
from astakos.im.util import get_context, prepare_response, get_query, restrict_next
from astakos.im.forms import (LoginForm, InvitationForm, ProfileForm,
FeedbackForm, SignApprovalTermsForm,
......@@ -87,6 +88,8 @@ from astakos.im.tasks import request_billing
from astakos.im.api.callpoint import AstakosCallpoint
import astakos.im.messages as astakos_messages
from astakos.im import settings
from astakos.im import auth_providers
logger = logging.getLogger(__name__)
......@@ -109,6 +112,26 @@ def render_response(template, tab=None, status=200, context_instance=None, **kwa
response = HttpResponse(html, status=status)
return response
def requires_auth_provider(provider_id, **perms):
"""
"""
def decorator(func, *args, **kwargs):
@wraps(func)
def wrapper(request, *args, **kwargs):
provider = auth_providers.get_provider(provider_id)
if not provider or not provider.is_active():
raise PermissionDenied
if provider:
for pkey, value in perms.iteritems():
attr = 'is_available_for_%s' % pkey.lower()
if getattr(provider, attr)() != value:
raise PermissionDenied
return func(request, *args)
return wrapper
return decorator
def requires_anonymous(func):
"""
......@@ -319,11 +342,19 @@ def edit_profile(request, template_name='im/profile.html', extra_context=None):
except ValueError, ve:
messages.success(request, ve)
elif request.method == "GET":
if not request.user.is_verified:
request.user.is_verified = True
request.user.save()
# existing providers
user_providers = request.user.get_active_auth_providers()
# providers that user can add
user_available_providers = request.user.get_available_auth_providers()
return render_response(template_name,
profile_form = form,
user_providers = user_providers,
user_available_providers = user_available_providers,
context_instance = get_context(request,
extra_context))
......@@ -370,6 +401,9 @@ def signup(request, template_name='im/signup.html', on_success='im/signup_comple
return HttpResponseRedirect(reverse('edit_profile'))
provider = get_query(request).get('provider', 'local')
if not auth_providers.get_provider(provider).is_available_for_create():
raise PermissionDenied
id = get_query(request).get('id')
try:
instance = AstakosUser.objects.get(id=id) if id else None
......@@ -390,7 +424,9 @@ def signup(request, template_name='im/signup.html', on_success='im/signup_comple
result = backend.handle_activation(user)
status = messages.SUCCESS
message = result.message
user.save()
form.store_user(user, request)
if 'additional_email' in form.cleaned_data:
additional_email = form.cleaned_data['additional_email']
if additional_email != user.email:
......@@ -406,6 +442,7 @@ def signup(request, template_name='im/signup.html', on_success='im/signup_comple
transaction.commit()
return response
messages.add_message(request, status, message)
transaction.commit()
return render_response(
on_success,
context_instance=get_context(
......@@ -655,6 +692,10 @@ def change_email(request, activation_key=None,
def send_activation(request, user_id, template_name='im/login.html', extra_context=None):
if settings.MODERATION_ENABLED:
raise PermissionDenied
extra_context = extra_context or {}
try:
u = AstakosUser.objects.get(id=user_id)
......@@ -1365,6 +1406,7 @@ def timeline(request):
timeline_body=timeline_body)
return data
# TODO: action only on POST and user should confirm the removal
@require_http_methods(["GET", "POST"])
@login_required
......@@ -1381,7 +1423,9 @@ def remove_auth_provider(request, pk):
else:
raise PermissionDenied
def how_it_works(request):
return render_response(
template='im/how_it_works.html',
context_instance=get_context(request),)
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment