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 = query.one()
log.debug('Drupal user found in CKAN: %s', user.name)
if user.email != user_dict['email'] or \
if user.id != drupal_user_id or \
user.email != user_dict['email'] or \
user.name != user_dict['name'] or \
user.fullname != user_dict['fullname'] or \
user.state == 'deleted':
user.id = drupal_user_id
user.email = user_dict['email']
user.name = 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.email, user.name, user.fullname)
log.debug('User details updated from Drupal: %s %s %s %s',
user.id, user.email, user.name, user.fullname)
model.Session.commit()
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