Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capture user email ignoring case #108

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions ckanext/saml2auth/views/saml2auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from flask import Blueprint, session
from saml2 import entity
from saml2.authn_context import requested_authn_context

from sqlalchemy.sql import func
import ckan.plugins.toolkit as toolkit
import ckan.model as model
import ckan.plugins as plugins
Expand Down Expand Up @@ -76,13 +76,18 @@ def _get_user_by_saml_id(saml_id):

def _get_user_by_email(email):

user = model.User.by_email(email)
if user and isinstance(user, list):
user = user[0]
users = model.Session.query(model.User).filter(
func.lower(model.User.email) == func.lower(email)
).all()

h.activate_user_if_deleted(user)
if len(users) == 0:
return None
if len(users) > 1:
raise toolkit.ValidationError(f'Multiple users with the same email found {email}')

return _dictize_user(user) if user else None
user = users[0]
h.activate_user_if_deleted(user)
return _dictize_user(user)


def _update_user(user_dict):
Expand Down
Loading