Exemple #1
0
        public async Task When_Passing_Null_AuthorizationParameter_To_The_Action_AuthenticateResourceOwner_Then_Exception_Is_Thrown()
        {
            // ARRANGE
            InitializeFakeObjects();
            var authorizationParameter = new AuthorizationParameter();

            // ACT & ASSERT
            await Assert.ThrowsAsync <ArgumentNullException>(() => _authenticateActions.AuthenticateResourceOwnerOpenId(null, null, null, null));

            await Assert.ThrowsAsync <ArgumentNullException>(() => _authenticateActions.AuthenticateResourceOwnerOpenId(authorizationParameter, null, null, null));
        }
Exemple #2
0
        public async Task <ActionResult> OpenId(string code)
        {
            if (string.IsNullOrWhiteSpace(code))
            {
                throw new ArgumentNullException(nameof(code));
            }

            var authenticatedUser = await SetUser();

            var request      = _dataProtector.Unprotect <AuthorizationRequest>(code);
            var actionResult = await _authenticateActions.AuthenticateResourceOwnerOpenId(
                request.ToParameter(),
                authenticatedUser,
                code);

            var result = this.CreateRedirectionFromActionResult(actionResult,
                                                                request);

            if (result != null)
            {
                LogAuthenticateUser(actionResult, request.ProcessId);
                return(result);
            }

            await TranslateView(request.UiLocales);

            var viewModel = new AuthorizeOpenIdViewModel
            {
                Code = code
            };

            await SetIdProviders(viewModel);

            return(View(viewModel));
        }
Exemple #3
0
        public async Task <ActionResult> OpenId(string code)
        {
            if (string.IsNullOrWhiteSpace(code))
            {
                throw new ArgumentNullException(nameof(code));
            }

            var authenticatedUser = await this.GetAuthenticatedUser(Constants.CookieName);

            var request      = _dataProtector.Unprotect <AuthorizationRequest>(code);
            var actionResult = await _authenticateActions.AuthenticateResourceOwnerOpenId(
                request.ToParameter(),
                authenticatedUser,
                code);

            var result = this.CreateRedirectionFromActionResult(actionResult,
                                                                request);

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

            var viewModel = new LoginOpenIdViewModel
            {
                Code = code
            };

            return(View(viewModel));
        }