def login_user(request, user_data): request.security = Interaction(request) participation = GuillotinaParticipation(request) participation.interaction = None if 'id' in user_data: user = GuillotinaUser(request) user.id = user_data['id'] user._groups = user_data.get('groups', []) user._roles = user_data.get('roles', []) user.data = user_data.get('data', {}) participation.principal = user request._cache_user = user request.security.add(participation) request.security.invalidate_cache() request._cache_groups = {} if user_data.get('Authorization'): request.headers['Authorization'] = user_data['Authorization']
def login_user(request, user_data): """Logs user in to guillotina so the job has the correct access """ if 'id' in user_data: user = GuillotinaUser( user_id=user_data['id'], groups=user_data.get('groups', []), roles={name: Allow for name in user_data['roles']}) user.data = user_data.get('data', {}) set_authenticated_user(user) else: set_authenticated_user(None) if user_data.get('Authorization'): # leave in for b/w compat, remove at later date request.headers['Authorization'] = user_data['Authorization'] for name, value in (user_data.get('headers') or {}).items(): request.headers[name] = value
def login_user(request, user_data): """Logs user in to guillotina so the job has the correct access """ if "id" in user_data: user = GuillotinaUser( user_id=user_data["id"], groups=user_data.get("groups", []), roles={name: Allow for name in user_data["roles"]}, ) user.data = user_data.get("data", {}) set_authenticated_user(user) else: set_authenticated_user(None) if user_data.get("Authorization"): # leave in for b/w compat, remove at later date request.headers["Authorization"] = user_data["Authorization"] for name, value in (user_data.get("headers") or {}).items(): request.headers[name] = value