From 4e14a262829b763a6bcbd7e8fc376b51c1094509 Mon Sep 17 00:00:00 2001 From: Leif Johansson Date: Tue, 10 May 2011 09:44:56 +0200 Subject: export session as random password to acp --- src/meetingtools/ac/api.py | 13 +++++++++++-- src/meetingtools/apps/auth/views.py | 13 +++++++++++-- src/templates/apps/room/list.html | 22 +++++++++++++++------- 3 files changed, 37 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/meetingtools/ac/api.py b/src/meetingtools/ac/api.py index 59aa2d8..c26cd29 100644 --- a/src/meetingtools/ac/api.py +++ b/src/meetingtools/ac/api.py @@ -14,6 +14,7 @@ from lxml import etree import pprint from meetingtools.site_logging import logger import lxml +from django.http import HttpResponseRedirect class ACPException(Exception): def __init__(self, value): @@ -63,12 +64,13 @@ def _getset(dict,key,value=None): class ACPClient(): - def __init__(self,url,username=None,password=None): + def __init__(self,url,username=None,password=None,cache=True): self.url = url self.session = None if username and password: self.login(username,password) - self._cache = {'login':{},'group':{}} + if cache: + self._cache = {'login':{},'group':{}} def request(self,method,p={},raise_error=False): if self.session: @@ -99,10 +101,17 @@ class ACPClient(): return r; + def redirect_to(self,url): + if self.session: + return HttpResponseRedirect("%s?BREEZESESSION=%s" % (url,self.session)) + else: + return HttpResponseRedirect(url) + def login(self,username,password): result = self.request('login',{'login':username,'password':password}) if result.is_error(): raise result.exception() + return result def find_or_create_principal(self,key,value,type,dict): if not self._cache.has_key(type): diff --git a/src/meetingtools/apps/auth/views.py b/src/meetingtools/apps/auth/views.py index 8af2e1a..b1f9567 100644 --- a/src/meetingtools/apps/auth/views.py +++ b/src/meetingtools/apps/auth/views.py @@ -16,6 +16,7 @@ from django.shortcuts import render_to_response from django.contrib import auth from django_co_connector.models import co_import_from_request, add_member,\ remove_member +import random, string def meta(request,attr): v = request.META.get(attr) @@ -60,8 +61,7 @@ def login(request): def join_group(group,**kwargs): user = kwargs['user'] acc = _acc_for_user(user) - connect_api = ac_api(acc) - + connect_api = ac_api(acc) principal = connect_api.find_principal("login", user.username, "user") if principal: gp = connect_api.find_group(group.name) @@ -83,6 +83,11 @@ def leave_group(group,**kwargs): add_member.connect(join_group,sender=Group) remove_member.connect(leave_group,sender=Group) +def _random_key(length=20): + rg = random.SystemRandom() + alphabet = string.letters + string.digits + return str().join(rg.choice(alphabet) for _ in range(length)) + def accounts_login_federated(request): if request.user.is_authenticated(): profile,created = UserProfile.objects.get_or_create(user=request.user) @@ -127,12 +132,16 @@ def accounts_login_federated(request): acc = _acc_for_user(request.user) connect_api = ac_api_client(request, acc) # make sure the principal is created before shooting off + key = _random_key() + request.session['ac_key'] = key principal = connect_api.find_or_create_principal("login", request.user.username, "user", {'type': "user", 'has-children': "0", 'first-name':fn, 'last-name':ln, 'email':mail, + 'send-email': 0, + 'password': key, 'login':request.user.username, 'ext-login':request.user.username}) diff --git a/src/templates/apps/room/list.html b/src/templates/apps/room/list.html index 2ec375e..6c39e12 100644 --- a/src/templates/apps/room/list.html +++ b/src/templates/apps/room/list.html @@ -10,7 +10,8 @@ event: "click", collapsible: true, navigation: true, - animated: true + animated: true, + autoHeight: false }); {% endblock %} {% block content %} @@ -21,12 +22,19 @@

{{r.name}}

-

Created by {{r.creator}} {{r.timecreated|datehumanize}}.

-

Meeting room URL: {{r|roomurl}}

- +
    +
  • Created by {{r.creator}} {{r.timecreated|datehumanize}}.
  • + {% if r.lastvisited %}
  • Last visited {{r.lastvisited|datehumanize}}{% if r.user_count %}when there was {{r.user_count}} user{{r.user_count|pluralize}} in the room{%endif%}.
  • {%endif%} +
  • Meeting room URL: {{r|roomurl}}
  • +
+
+ {% if r.description %} +

{{r.description|safe}}

+ {% endif %} +
{% endfor %} -- cgit v1.1