Skip to content
Snippets Groups Projects
Commit e1fed194 authored by Ben Adida's avatar Ben Adida
Browse files

prevent password users from self-registering and add handling of google...

prevent password users from self-registering and add handling of google accounts without firstname/lastname
parent 823064e2
No related branches found
Tags v3.0.7
No related merge requests found
......@@ -32,7 +32,15 @@ def get_auth_url(request, redirect_url):
def get_user_info_after_auth(request):
data = view_helpers.finish_openid(request.session, request.GET, request.session['google_redirect_url'])
return {'type' : 'google', 'user_id': data['ax']['email'][0], 'name': "%s %s" % (data['ax']['firstname'][0], data['ax']['lastname'][0]), 'info': {}, 'token':{}}
email = data['ax']['email'][0]
# do we have a firstname/lastname?
if data['ax'].has_key('firstname') and data['ax'].has_key('lastname'):
name = "%s %s" % (data['ax']['firstname'][0], data['ax']['lastname'][0])
else:
name = email
return {'type' : 'google', 'user_id': email, 'name': name , 'info': {}, 'token':{}}
def do_logout(user):
"""
......
......@@ -708,6 +708,10 @@ def one_election_questions(request, election):
return render_template(request, 'election_questions', {'election': election, 'questions_json' : questions_json, 'admin_p': admin_p})
def _check_eligibility(election, user):
# prevent password-users from signing up willy-nilly for other elections, doesn't make sense
if user.user_type == 'password':
return False
return election.user_eligible_p(user)
def _register_voter(election, user):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment