Skip to content

Throws internal server error in CKAN v2.9 #3

@anuveyatsu

Description

@anuveyatsu

Acceptance criteria

  • I can login a user via API in CKAN v2.9 instance.

Tasks

  • Analyze the issue
  • Propose the solution
  • Commit the solution

Analysis

This line of code https://github.com/datopian/ckanext-auth/blob/master/ckanext/auth/logic.py#L30 is calling authenticate method from ckan.lib.authenticator.

In CKAN v2.8 it was returning user.name, but in CKAN v2.9 it is returning a string in format user.id, 1

Solution

We need to get user name with:

authUser_id = auth.authenticate(context, identity).split(',')[0]
authUser_name = model.User.get(authUser_id).name

instead of:

authUser = auth.authenticate(context, identity)

because it is returning user.id, 1 as a string.

In CKAN v2.10 this changed again, so this authenticate method is returning the whole user object

If this is urgent we can apply the solution and keep it in a branch. In opposite, I can create one robust solution where we'll check CKAN version and handle user data in a way to be compatible with CKAN version.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions