Changeset 8769


Ignore:
Timestamp:
08/05/13 12:04:04 (6 years ago)
Author:
mnagni
Message:

Complete - # 22698: [CEDA Site Python Port] MyCEDA Login needs to be more user-friendly
 http://team.ceda.ac.uk/trac/ceda/ticket/22698

Location:
mauRepo/dj_security/trunk/dj_security
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • mauRepo/dj_security/trunk/dj_security/templates/signin.html

    r8767 r8769  
    2929 
    3030 
    31 {% if msg %} 
    32 <br /> 
    33         <p class="warning">{{ msg }}</p> 
     31{% if messages %} 
     32<ul class="messages"> 
     33    {% for message in messages %} 
     34    <li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li> 
     35    {% endfor %} 
     36</ul> 
    3437{% endif %} 
    3538<!-- 
  • mauRepo/dj_security/trunk/dj_security/views/dj_security_login.py

    r8760 r8769  
    1414from django.contrib.auth.backends import ModelBackend 
    1515from django.shortcuts import render_to_response as render 
     16from django.contrib import messages 
    1617 
    1718from userdb_model.models import User 
     
    3031from dj_security.exception import DSJOpenIDNotFoundError 
    3132from dj_security.middleware import _encode_authenticated_response 
     33from django.core.exceptions import ObjectDoesNotExist 
    3234 
    3335# Get an instance of a logger 
     
    8183    try: 
    8284        return User.objects.get(openid=user_id) 
    83     except DatabaseError as ex: 
     85    except (DatabaseError, ObjectDoesNotExist) as ex: 
    8486        logging.error("Openid: %s - Not Found" % user_id) 
    8587        raise DSJOpenIDNotFoundError(ex)    
     
    197199     
    198200    if OPENID in request.REQUEST: 
    199         return _encode_authenticated_response(request,  
     201        try: 
     202            return _encode_authenticated_response(request,  
    200203                                response,  
    201204                                redirect_url,  
    202                                 get_user_byopenid(request.REQUEST[OPENID]))             
     205                                get_user_byopenid(request.REQUEST[OPENID])) 
     206        except DSJOpenIDNotFoundError as e: 
     207            msg = "No user associated with OPENID %s" % (request.REQUEST[OPENID]) 
     208            messages.add_message(request, messages.WARNING, msg) 
     209            LOGGER.warn(msg) 
     210            return HttpResponseRedirect(request.environ['HTTP_REFERER'])                         
    203211    elif SESSION_KEY in request.session: 
    204212        response = HttpResponseRedirect(redirect_url) 
Note: See TracChangeset for help on using the changeset viewer.