Commit a6f902b8 authored by Marko Kuder's avatar Marko Kuder
Browse files

can we change id to sync user?

parent 8dbd2475
......@@ -214,6 +214,8 @@ class DrupalAuthMiddleware(object):
from ckan import model
from ckan.model.meta import Session
query = Session.query(model.User).filter_by(id=drupal_user_id)
if not query.count():
query = Session.query(model.User).filter_by(name=ckan_user_name)
if not query.count():
# need to add this user to CKAN
user = model.User(**user_dict)
......@@ -224,18 +226,20 @@ class DrupalAuthMiddleware(object):
user =
log.debug('Drupal user found in CKAN: %s',
if != user_dict['email'] or \
if != drupal_user_id or \ != user_dict['email'] or \ != user_dict['name'] or \
user.fullname != user_dict['fullname'] or \
user.state == 'deleted': = drupal_user_id = user_dict['email'] = user_dict['name']
user.fullname = user_dict['fullname']
if user.state == 'deleted':
log.debug('User was deleted, changing state back to active.')
user.state = 'active'
log.debug('User details updated from Drupal: %s %s %s',,, user.fullname)
log.debug('User details updated from Drupal: %s %s %s %s',,,, user.fullname)
self.set_roles(ckan_user_name, drupal_user_properties['roles'].values())
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