Skip to content
Snippets Groups Projects
Commit 0447e51a authored by Benedikt Heinrichs's avatar Benedikt Heinrichs
Browse files

Update: Login on merge with same provider results in merge token removed and...

Update: Login on merge with same provider results in merge token removed and login to Coscine (coscine/issues#2592)
parent 9f8009f8
No related tags found
1 merge request!148Update: Login on merge with same provider results in merge token removed and login to Coscine
...@@ -86,14 +86,14 @@ namespace Coscine.Api.STS.Controllers ...@@ -86,14 +86,14 @@ namespace Coscine.Api.STS.Controllers
} }
} }
if (validMerge && contents != null && contents.Any((claim) => claim.Type == "UserGuid")) if (validMerge && contents?.Any((claim) => claim.Type == "UserGuid") == true)
{ {
var userGuidString = contents.Where((claim) => claim.Type == "UserGuid").First(); var userGuidString = contents.First((claim) => claim.Type == "UserGuid");
var correctGuid = Guid.TryParse(userGuidString.Value, out Guid userGuid); var correctGuid = Guid.TryParse(userGuidString.Value, out Guid userGuid);
if (correctGuid) if (correctGuid)
{ {
var userList = userModel.GetAllWhere((user) => user.Id == userGuid); var userList = userModel.GetAllWhere((user) => user.Id == userGuid);
if (userList.Count() > 0) if (userList.Any())
{ {
var mergeIntoUser = userList.First(); var mergeIntoUser = userList.First();
...@@ -116,7 +116,18 @@ namespace Coscine.Api.STS.Controllers ...@@ -116,7 +116,18 @@ namespace Coscine.Api.STS.Controllers
} }
} }
} }
}
else if (contents?.Any((claim) => claim.Type == "UserGuid") == true)
{
var userGuidString = contents.First((claim) => claim.Type == "UserGuid");
var coscineUser = new CoscineUser()
{
UserName = userGuidString.Value,
Email = ""
};
await _signInManager.SignInAsync(coscineUser, isPersistent: false);
return Redirect(UrlGenerator.ExtendReturnUrl(returnUrl, Request));
} }
string loginUrl = UrlGenerator.GetLoginUrl(Request); string loginUrl = UrlGenerator.GetLoginUrl(Request);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment