Esempio n. 1
0
        public async Task <TUser> FindByLoginAsync(string loginProvider, string providerKey, CancellationToken cancellationToken)
        {
            ThrowIfDisposed();
            cancellationToken.ThrowIfCancellationRequested();
            log.LogDebug("FindAsync called for " + loginProvider + " with providerKey " + providerKey);

            Guid siteGuid = siteSettings.Id;

            if (multiTenantOptions.UseRelatedSitesMode)
            {
                siteGuid = multiTenantOptions.RelatedSiteId;
            }

            var userlogin = await queries.FindLogin(siteGuid, loginProvider, providerKey, cancellationToken);

            if (userlogin != null && userlogin.UserId != Guid.Empty)
            {
                log.LogDebug("FindAsync userLogin found for " + loginProvider + " with providerKey " + providerKey);

                cancellationToken.ThrowIfCancellationRequested();
                var siteUser = await queries.Fetch(siteGuid, userlogin.UserId, cancellationToken);

                if (siteUser != null)
                {
                    return((TUser)siteUser);
                }
                else
                {
                    log.LogDebug("FindAsync siteUser not found for " + loginProvider + " with providerKey " + providerKey);
                }
            }
            else
            {
                log.LogDebug("FindAsync userLogin not found for " + loginProvider + " with providerKey " + providerKey);
            }

            return(default(TUser));
        }