示例#1
0
        public async Task <IActionResult> Login(string returnUrl)
        {
            var localLoginOutput = await _localLoginInteractor.ExecuteAsync(returnUrl);

            if (localLoginOutput.IsExternalLoginOnly)
            {
                return(RedirectToAction("Challenge", "ExternalLogin",
                                        new { scheme = localLoginOutput.ExternalLoginScheme, returnUrl }));
            }

            var vm = BuildLoginViewModel(localLoginOutput, returnUrl);

            return(View(vm));
        }
示例#2
0
        public async Task ExecuteAsync_Should_Return_LocalLoginOutput_With_LocalLoginEnabled_True_And_Empty_External_Providers_When_Idenity_Provider_Exists_And_Is_Local_()
        {
            const string redirectUri    = "http://localhost";
            var          authRequest    = new AuthorizationRequest(AuthConstants.LocalIdentityProvider, "clientId", redirectUri);
            var          scheme         = new AuthenticationScheme("Google", "Google");
            var          expectedResult = new LocalLoginOutput(true, new List <LocalLoginExternalProviderOutput>());


            _authorizationServiceMock.Setup(x => x.GetAuthorizationRequestAsync(It.IsAny <string>()))
            .ReturnsAsync(authRequest);
            _schemeServiceMock.Setup(x => x.GetSchemeAsync(It.IsAny <string>())).ReturnsAsync(scheme);

            var result = await _localLoginInteractor.ExecuteAsync(redirectUri);

            result.Should().BeEquivalentTo(expectedResult);
        }