U4-9908 - Unable to link external login

Created by Pavel Budík 12 May 2017, 15:02:46 Updated by Shannon Deminick 24 May 2017, 05:39:25

Tags: Unscheduled

Subtask of: U4-9609

After 7.6.1 upgrade, it is no longer possible to link user account to an external ID via external login provider. After the external login workflow completes (redirect to external login, redirect back to backoffice), everything seems fine, except that the account is not linked.

The issue is caused by the DB transaction which inserts the new binding into the umbracoExternalLogin table being aborted. That is caused by the new scopes framework. ExternalLoginService leaks scopes [here|https://github.com/umbraco/Umbraco-CMS/blob/release-7.6.1/src/Umbraco.Core/Services/ExternalLoginService.cs#L30] and [here|https://github.com/umbraco/Umbraco-CMS/blob/release-7.6.1/src/Umbraco.Core/Services/ExternalLoginService.cs#L47] -- the GetByQuery methods are not executed until the returned IEnumerables are enumerated (because of WhereNotNull() [lazy evaluation|https://github.com/umbraco/Umbraco-CMS/blob/release-7.6.1/src/Umbraco.Core/Persistence/Repositories/RepositoryBase.cs#L280]). However, at this moment, the enclosing scope is already completed, causing trouble for the following scopes (especially the one creating the external login record). Detailed explanation is a little complicated and I'm must admit I don't understand the scopes framework very well...

A solution could be to add .ToList() somwhere -- either to the GetByQuery method (which would solve possible issues for all repositories) or just to those two aforementioned methods... Have tried it and it works but I'm not sure it wouldn't cause some other errors elsewhere.


Sebastiaan Janssen 15 May 2017, 20:20:05

@zpqrtbnk Can you investigate this please?

Stephan 16 May 2017, 06:11:02

PR https://github.com/umbraco/Umbraco-CMS/pull/1948

Review = should work.

Amazing bug report BTW.

Pavel Budík 16 May 2017, 06:44:44

Thanks :). After spending some hours debugging the oauth process itself, a few more diving into the new scopes fw were fun :)

Priority: Normal

Type: Bug

State: Fixed


Difficulty: Normal


Backwards Compatible: True

Fix Submitted:

Affected versions: 7.6.1

Due in version: 7.6.2


Story Points:

Cycle: 1