Skip to content
Snippets Groups Projects
Commit 85def862 authored by juanf's avatar juanf
Browse files

SSDM-13362: Bugfix, Personal access tokens do not work if emails are used for login

parent 6bf6a294
No related branches found
No related tags found
1 merge request!40SSDM-13578 : 2PT : Database and V3 Implementation - include the new AFS "free"...
...@@ -318,25 +318,40 @@ public class PersonalAccessTokenOpenBisSessionManagerDecorator implements IOpenB ...@@ -318,25 +318,40 @@ public class PersonalAccessTokenOpenBisSessionManagerDecorator implements IOpenB
{ {
try try
{ {
final Principal principal = authenticationService.getPrincipal(patSession.getOwnerId());
if (principal == null) PersonPE person = daoFactory.getPersonDAO().tryFindPersonByUserId(patSession.getOwnerId());
if (person == null)
{ {
operationLog.warn("Ignoring a personal access token session (" + patSession operationLog.warn("Ignoring a personal access token session (" + patSession
+ ") because the session's owner was not found by the authentication service."); + ") because the session's owner was not found in the openBIS database.");
return null; return null;
} else
{
principal.setAuthenticated(true);
} }
PersonPE person = daoFactory.getPersonDAO().tryFindPersonByUserId(patSession.getOwnerId()); Principal principal = null;
try
{
principal = authenticationService.getPrincipal(patSession.getOwnerId());
} catch (Exception ex1) {
try
{
if (authenticationService.supportsAuthenticatingByEmail())
{
principal = authenticationService.getPrincipal(person.getEmail());
}
} catch (Exception ex2) {
operationLog.warn(ex2);
}
}
if (person == null) if (principal == null)
{ {
operationLog.warn("Ignoring a personal access token session (" + patSession operationLog.warn("Ignoring a personal access token session (" + patSession
+ ") because the session's owner was not found in the openBIS database."); + ") because the session's owner was not found by the authentication service.");
return null; return null;
} else
{
principal.setAuthenticated(true);
} }
final Session session = sessionFactory.create(patSession.getHash(), patSession.getOwnerId(), principal, getRemoteHost(), final Session session = sessionFactory.create(patSession.getHash(), patSession.getOwnerId(), principal, getRemoteHost(),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment