summaryrefslogtreecommitdiff
path: root/src/meetingtools/apps
diff options
context:
space:
mode:
authorLeif Johansson <leifj@sunet.se>2011-05-10 09:44:56 +0200
committerLeif Johansson <leifj@sunet.se>2011-05-10 09:44:56 +0200
commit4e14a262829b763a6bcbd7e8fc376b51c1094509 (patch)
tree5cbafe2fd4aa6f6a96debe88e20eb987d5e5e54c /src/meetingtools/apps
parent4dccf3f3a8b06d47122e8e9ac995af0eee9bcec7 (diff)
export session as random password to acp
Diffstat (limited to 'src/meetingtools/apps')
-rw-r--r--src/meetingtools/apps/auth/views.py13
1 files changed, 11 insertions, 2 deletions
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})