Ignore:
Timestamp:
10 Dec 2014, 11:12:42 (10 years ago)
Author:
Henrik Bettermann
Message:

We need to check if imported roles do exist.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/authentication.py

    r11949 r12189  
    4040    IBatchProcessor, IGNORE_MARKER, IFailedLoginInfo)
    4141from waeup.ikoba.utils.batching import BatchProcessor
     42from waeup.ikoba.permissions import get_all_roles
    4243
    4344def setup_authentication(pau):
     
    513514        return
    514515
     516    def checkConversion(self, row, mode='ignore'):
     517        """Validates all values in row.
     518        """
     519        errs, inv_errs, conv_dict = super(
     520            UserProcessor, self).checkConversion(row, mode=mode)
     521        # We need to check if roles exist.
     522        roles = row.get('roles', None)
     523        all_roles = [i[0] for i in get_all_roles()]
     524        if roles not in ('', IGNORE_MARKER):
     525            evalvalue = eval(roles)
     526            for role in evalvalue:
     527                if role not in all_roles:
     528                    errs.append(('roles','invalid role'))
     529        return errs, inv_errs, conv_dict
     530
    515531class UsersPlugin(grok.GlobalUtility):
    516532    """A plugin that updates users.
Note: See TracChangeset for help on using the changeset viewer.