prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  current_user.is_anonymous doesn't care if context has an user
  ## CKAN version
  2.10
  
  ## Describe the bug
  While looking into why https://github.com/ckan/ckan/pull/7266 started failing on unmodified ckan, I noticed that deciphering anonymous users has changed. On 2.9 `restrict_anon` works as follows 
  https://github.com/ckan/ckan/blob/c4e2818818e08e60bb69d64229f8dbba531f8439/ckan/logic/auth/__init__.py#L51-L55
  
  where `authz.auth_is_anon_user` checks if the context has an user in it. On 2.10 the functionality has changed:
  
  https://github.com/ckan/ckan/blob/d46613e346f9dc551aedb54c8c24baad919f78c1/ckan/logic/auth/__init__.py#L93-L97
  
  which does not check for context at all and the password reset started failing on 2.10. Should the `is_anonymous` check for user in context or are we just relying on what flask login says about the user? 
  
  
  
  </issue>
  <code>
  [start of ckan/logic/auth/__init__.py]
  1 # encoding: utf-8
  2 
  3 '''
  4 Helper functions to be used in the auth check functions
  5 '''
  6 
  7 from typing import Any, Optional, TYPE_CHECKING, overload
  8 from typing_extensions import Literal
  9 
  10 import ckan.logic as logic
  11 from ckan.types import Context, AuthResult, DataDict
  12 from ckan.common import current_user
  13 
  14 if TYPE_CHECKING:
  15     import ckan.model as model_
  16 
  17 
  18 @overload
  19 def _get_object(context: Context,
  20                 data_dict: Optional[DataDict], name: str,
  21                 class_name: Literal['Package']) -> 'model_.Package':
  22     ...
  23 
  24 
  25 @overload
  26 def _get_object(context: Context,
  27                 data_dict: Optional[DataDict], name: str,
  28                 class_name: Literal['Resource']) -> 'model_.Resource':
  29     ...
  30 
  31 
  32 @overload
  33 def _get_object(context: Context,
  34                 data_dict: Optional[DataDict], name: str,
  35                 class_name: Literal['Group']) -> 'model_.Group':
  36     ...
  37 
  38 
  39 @overload
  40 def _get_object(context: Context,
  41                 data_dict: Optional[DataDict], name: str,
  42                 class_name: Literal['User']) -> 'model_.User':
  43     ...
  44 
  45 
  46 def _get_object(context: Context,
  47                 data_dict: Optional[DataDict], name: str,
  48                 class_name: str) -> Any:
  49     # return the named item from model.class_name
  50     model = context['model']
  51     if not data_dict:
  52         data_dict = {}
  53     id = data_dict.get('id', None)
  54     if not id:
  55         raise logic.ValidationError({
  56             "message": 'Missing id, can not get {0} object'.format(
  57                 class_name)})
  58     obj = getattr(model, class_name).get(id)
  59     if not obj:
  60         raise logic.NotFound
  61     return obj
  62 
  63 
  64 def get_package_object(
  65         context: Context,
  66         data_dict: Optional[DataDict] = None) -> 'model_.Package':
  67     return _get_object(context, data_dict, 'package', 'Package')
  68 
  69 
  70 def get_resource_object(
  71         context: Context,
  72         data_dict: Optional[DataDict] = None) -> 'model_.Resource':
  73     return _get_object(context, data_dict, 'resource', 'Resource')
  74 
  75 
  76 def get_group_object(
  77         context: Context,
  78         data_dict: Optional[DataDict] = None) -> 'model_.Group':
  79     return _get_object(context, data_dict, 'group', 'Group')
  80 
  81 
  82 def get_user_object(
  83         context: Context,
  84         data_dict: Optional[DataDict] = None) -> 'model_.User':
  85     return _get_object(context, data_dict, 'user_obj', 'User')
  86 
  87 
  88 def restrict_anon(context: Context) -> AuthResult:
  89     if current_user.is_anonymous:
  90         return {'success': False}
  91     else:
  92         return {'success': True}
  93
  [end of ckan/logic/auth/__init__.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/ckan/logic/auth/__init__.py b/ckan/logic/auth/__init__.py
  --- a/ckan/logic/auth/__init__.py
  +++ b/ckan/logic/auth/__init__.py
  @@ -8,8 +8,8 @@
   from typing_extensions import Literal
   
   import ckan.logic as logic
  +import ckan.authz as authz
   from ckan.types import Context, AuthResult, DataDict
  -from ckan.common import current_user
   
   if TYPE_CHECKING:
       import ckan.model as model_
  @@ -86,7 +86,7 @@
   
   
   def restrict_anon(context: Context) -> AuthResult:
  -    if current_user.is_anonymous:
  +    if authz.auth_is_anon_user(context):
           return {'success': False}
       else:
           return {'success': True}
  
verification_info: {"golden_diff": "diff --git a/ckan/logic/auth/__init__.py b/ckan/logic/auth/__init__.py\n--- a/ckan/logic/auth/__init__.py\n+++ b/ckan/logic/auth/__init__.py\n@@ -8,8 +8,8 @@\n from typing_extensions import Literal\n \n import ckan.logic as logic\n+import ckan.authz as authz\n from ckan.types import Context, AuthResult, DataDict\n-from ckan.common import current_user\n \n if TYPE_CHECKING:\n     import ckan.model as model_\n@@ -86,7 +86,7 @@\n \n \n def restrict_anon(context: Context) -> AuthResult:\n-    if current_user.is_anonymous:\n+    if authz.auth_is_anon_user(context):\n         return {'success': False}\n     else:\n         return {'success': True}\n", "issue": "current_user.is_anonymous doesn't care if context has an user\n## CKAN version\r\n2.10\r\n\r\n## Describe the bug\r\nWhile looking into why https://github.com/ckan/ckan/pull/7266 started failing on unmodified ckan, I noticed that deciphering anonymous users has changed. On 2.9 `restrict_anon` works as follows \r\nhttps://github.com/ckan/ckan/blob/c4e2818818e08e60bb69d64229f8dbba531f8439/ckan/logic/auth/__init__.py#L51-L55\r\n\r\nwhere `authz.auth_is_anon_user` checks if the context has an user in it. On 2.10 the functionality has changed:\r\n\r\nhttps://github.com/ckan/ckan/blob/d46613e346f9dc551aedb54c8c24baad919f78c1/ckan/logic/auth/__init__.py#L93-L97\r\n\r\nwhich does not check for context at all and the password reset started failing on 2.10. Should the `is_anonymous` check for user in context or are we just relying on what flask login says about the user? \r\n\r\n\n", "before_files": [{"content": "# encoding: utf-8\n\n'''\nHelper functions to be used in the auth check functions\n'''\n\nfrom typing import Any, Optional, TYPE_CHECKING, overload\nfrom typing_extensions import Literal\n\nimport ckan.logic as logic\nfrom ckan.types import Context, AuthResult, DataDict\nfrom ckan.common import current_user\n\nif TYPE_CHECKING:\n    import ckan.model as model_\n\n\n@overload\ndef _get_object(context: Context,\n                data_dict: Optional[DataDict], name: str,\n                class_name: Literal['Package']) -> 'model_.Package':\n    ...\n\n\n@overload\ndef _get_object(context: Context,\n                data_dict: Optional[DataDict], name: str,\n                class_name: Literal['Resource']) -> 'model_.Resource':\n    ...\n\n\n@overload\ndef _get_object(context: Context,\n                data_dict: Optional[DataDict], name: str,\n                class_name: Literal['Group']) -> 'model_.Group':\n    ...\n\n\n@overload\ndef _get_object(context: Context,\n                data_dict: Optional[DataDict], name: str,\n                class_name: Literal['User']) -> 'model_.User':\n    ...\n\n\ndef _get_object(context: Context,\n                data_dict: Optional[DataDict], name: str,\n                class_name: str) -> Any:\n    # return the named item from model.class_name\n    model = context['model']\n    if not data_dict:\n        data_dict = {}\n    id = data_dict.get('id', None)\n    if not id:\n        raise logic.ValidationError({\n            \"message\": 'Missing id, can not get {0} object'.format(\n                class_name)})\n    obj = getattr(model, class_name).get(id)\n    if not obj:\n        raise logic.NotFound\n    return obj\n\n\ndef get_package_object(\n        context: Context,\n        data_dict: Optional[DataDict] = None) -> 'model_.Package':\n    return _get_object(context, data_dict, 'package', 'Package')\n\n\ndef get_resource_object(\n        context: Context,\n        data_dict: Optional[DataDict] = None) -> 'model_.Resource':\n    return _get_object(context, data_dict, 'resource', 'Resource')\n\n\ndef get_group_object(\n        context: Context,\n        data_dict: Optional[DataDict] = None) -> 'model_.Group':\n    return _get_object(context, data_dict, 'group', 'Group')\n\n\ndef get_user_object(\n        context: Context,\n        data_dict: Optional[DataDict] = None) -> 'model_.User':\n    return _get_object(context, data_dict, 'user_obj', 'User')\n\n\ndef restrict_anon(context: Context) -> AuthResult:\n    if current_user.is_anonymous:\n        return {'success': False}\n    else:\n        return {'success': True}\n", "path": "ckan/logic/auth/__init__.py"}]}