コード例 #1
0
        // Violation of CQS, but we are not master of the Google identifiers...
        public async Task <User> ActivateGooglePlusUser(string accessToken)
        {
            if (accessToken == null)
            {
                throw new ArgumentNullException(nameof(accessToken));
            }
            var correlationId = await _googleUserDataService.ActivateGooglePlusUser(accessToken);

            var knownUsers = (await _knownUserDataService.FindKnownUserByCorrelationId((char)UserType.GooglePlus, correlationId)).ToList();

            if (knownUsers.Count > 1)
            {
                throw new SecurityException("Google authentication succeeded, but multiple locally known users were found.");
            }
            if (!knownUsers.Any())
            {
                throw new SecurityException("Google authentication succeeded, but no known user could be found.");
            }
            return(_userAdapter.Adapt(knownUsers.Single()));
        }