Пример #1
0
        protected virtual async Task <AuthenticateResult> ProcessNewExternalAccountAsync(string tenant, string provider, string providerId, IEnumerable <Claim> claims)
        {
            var user = await TryGetExistingUserFromExternalProviderClaimsAsync(provider, claims);

            if (user == null)
            {
                user = await InstantiateNewAccountFromExternalProviderAsync(provider, providerId, claims);

                var email = claims.GetValue(Constants.ClaimTypes.Email);

                user = userAccountService.CreateAccount(
                    tenant,
                    Guid.NewGuid().ToString("N"),
                    null, email,
                    null, null,
                    user);
            }

            userAccountService.AddOrUpdateLinkedAccount(user, provider, providerId);

            var result = await AccountCreatedFromExternalProviderAsync(user.ID, provider, providerId, claims);

            if (result != null)
            {
                return(result);
            }

            return(await SignInFromExternalProviderAsync(user.ID, provider));
        }
        protected virtual async Task <ExternalAuthenticateResult> ProcessNewExternalAccountAsync(string provider, string providerId, IEnumerable <Claim> claims)
        {
            var acct = userAccountService.CreateAccount(Guid.NewGuid().ToString("N"), null, null);

            userAccountService.AddOrUpdateLinkedAccount(acct, provider, providerId);

            var result = await AccountCreatedFromExternalProviderAsync(acct.ID, provider, providerId, claims);

            if (result != null)
            {
                return(result);
            }

            return(await SignInFromExternalProviderAsync(acct.ID, provider));
        }